Commit Graph

988 Commits

Author SHA1 Message Date
Mark Paluch
69e6958aa2 DATACMNS-1683 - Polishing.
Trim trailing whitespaces.

Original pull request: #434.
2020-03-17 11:01:24 +01:00
Mark Paluch
54d9f01619 DATACMNS-658 - Polishing.
Introduce caseSensitive() flag to `@SortDefault`. Move sort spec parsing into parser class. Update documentation.

Original pull request: #172.
2020-03-11 10:18:54 +01:00
Dan Nawrocki
9ef3099711 DATACMNS-658 - Add IgnoreCase ordering option to SortHandlerMethodArgumentResolver.
We now pick up case-insensitive sorting flags by parsing it up from a sort query string argument.

To enable ignore case for one or more properties, we expect "ignorecase" as last element in a sort spec. Sort order and case-sensitivity options are parsed case-insensitive for a greater flexibility:

http://localhost/?sort=firstname,IgnoreCase or http://localhost/?sort=firstname,ASC,ignorecase

Original pull request: #172.
2020-03-11 10:15:29 +01:00
Mark Paluch
4bd49f3f01 DATACMNS-1679 - Make ReactiveWrappers.ReactiveLibrary public.
Fix visibility for type that is used in the public API.
2020-03-11 08:47:42 +01:00
Mark Paluch
ed7561a880 DATACMNS-1673 - Polishing.
Convert instance field to constant. Use parameter count for iteration instead of cloning the parameter array.

Original pull request: #426.
2020-02-25 09:43:16 +01:00
SergiiTsypanov
eaaa37d4ff DATACMNS-1673 - Polishing.
Use method references where possible. Cleanup generics. Omit superfluous calls.

Original pull request: #426.
2020-02-25 09:39:17 +01:00
SergiiTsypanov
5f3102144c DATACMNS-1673 - Use Method.getParameterCount() where possible to improve performance.
Original pull request: #426.
2020-02-25 09:39:12 +01:00
wonwoo
12b9850a85 DATACMNS-1672 - Fix typos in Javadoc.
Original pull request: #431.
2020-02-25 09:23:52 +01:00
Henri
f0d7a657fc DATACMNS-1212 - Remove unnecessary conversion between Instant and ZonedDateTime.
Converting from instant to ZoneDateTime and back to Instant does not seem to have a purpose as the timezone information will never be used

Original pull request: #260.
2020-02-12 12:02:14 +01:00
Mark Paluch
ea9c6176af DATACMNS-1666 - Deprecate Joda-Time and ThreeTenBackport support.
Joda-Time and ThreeTenBackport converters are now deprecated in favor of JSR-310 (java.time) support. These converters are now in maintenance mode without receiving future enhancements.
2020-02-12 10:52:07 +01:00
Mark Paluch
148c859be6 DATACMNS-1665 - Consider store conversions as ConverterRegistrationIntent.
Store converters are now properly considered as registration candidates.

Original Pull Request: #430
2020-02-11 10:28:07 +01:00
Mark Paluch
09153baf62 DATACMNS-1615 - Polishing.
Replace list creation with constant. Replace ConverterConfiguration.skipFor list with Predicate for flexible conditions. Fix typo. Simplify conditionals.

Original pull request: #421.
2020-02-07 12:14:05 +01:00
Christoph Strobl
dbcf9aefff DATACMNS-1615 - Allow fine grained store specific converter registration.
CustomConversions now registers all given user defined converters and selects only those converters from the StoreConversions that convert to or from a store supported simple type.
By doing so we make sure to only register supported converters which removes warning messages from the log and reduces the number of converters within the ConversionService.

Original pull request: #421.
2020-02-07 12:13:54 +01:00
Oliver Drotbohm
d5786edec7 DATACMNS-1610 - Polishing. 2020-02-03 13:53:17 +01:00
Oliver Drotbohm
5cdb3139a4 DATACMNS-1610 - Improved property path access.
We now expose a dedicated PersistentPropertyPathAccessor and optionally take options for both the read and write access to properties. On read, clients can define to eagerly receive null in case one of the path segments is null. By default, we reject those as it indicates that there might be an issue with the backing object if the client assumes it can look up the more deeply nested path to receive a result.

On write access clients can define to either reject, skip or log intermediate null segments where skip means, that the setting is just silently aborted. Clients can also control how to deal with collection and map intermediates. By default we now propagate the attempt to set a value to all collection or map items respectively. This could be potentially extended to provide a filter receiving both the property and property value to selectively propagate those calls in the future.

The separation of these APIs (PersistentPropertyAccessor and PersistentPropertyPathAccessor) is introduced as the latter can be implemented on top of the former and the former potentially being dynamically generated. The logic of the latter can then be clearly separated from the actual individual property lookup. ConvertingPropertyAccessor is now a PersistentPropertyPathAccessor, too, and overrides SimplePersistentPropertyPathAccessor.getTypedProperty(…) to plug in conversion logic. This allows custom collection types being used if the ConversionService backing the accessor can convert from and to Collection or Map respectively.

Deprecated all PersistentPropertyPath-related methods on PersistentPropertyAccessor for removal in 2.3.

MappingAuditableBeanWrapperFactory now uses these new settings to skip both null values as well as collection and map values when setting auditing metadata.

Related tickets: DATACMNS-1438, DATACMNS-1461, DATACMNS-1609.
2020-02-03 13:11:44 +01:00
Oliver Drotbohm
d05dd24a4b DATACMNS-1639 - Re-instantiate API in legacy EntityInstantiators.
To retain backwards compatibility for the legacy EntityInstantiators API, we now adapt the map values for custom instantiators that are handed into the constructors of EntityInstantiators.
2020-01-16 14:47:32 +01:00
Christoph Strobl
769b0f6af5 DATACMNS-1508 - Polishing.
Add findAllById, deleteAll to CoroutineCrudRepository.

Keep CoroutineCrudRepository somewhat in sync with ReactiveCrudRepository by adding based methods for those accecpting Publisher.
Also add some test.

Update License Headers of Kotlin files and fix some warnings. Switch to kotlin-test-junit5.

Original pull request: #415.
2020-01-16 11:28:39 +01:00
Mark Paluch
93c708379e DATACMNS-1508 - Address review comments.
Added ClassUtils.ifPresent(…) to conditionally call back a Consumer<Class> if a class is available from the given ClassLoader. Extract isSuspend(…) method into KotlinReflectionUtils. Deprecate Kotlin-related methods in our ReflectionUtils as parts are available from Spring Framework directly.

Rename CoCrudRepository to CoroutineCrudRepository and CoroutineSortingRepository. Add tests for KotlinReflectionUtils to test calls without Kotlin dependencies.

Original pull request: #415.
2020-01-16 11:28:39 +01:00
Mark Paluch
c945fa4f9a DATACMNS-949 - Drop own converters in favor of ReactiveAdapterRegistry.
We now reuse ReactiveAdapterRegistry as much as possible instead of registering our own converters.

Original pull request: #415.
2020-01-16 11:28:39 +01:00
Mark Paluch
ce7683c672 DATACMNS-1508 - Support for Kotlin Coroutines repositories.
We now support Kotlin Coroutines repositories backed by reactive repositories. Coroutine repositories can either invoke reactive query methods or implemented methods that are backed either by methods returning a reactive wrapper or that are native suspended functions.

Exclude Coroutines Continuation from bindable parameters and name discovery and do not unwrap results for suspended functions returning a reactive type.

interface CoroutinesRepository : CoroutineCrudRepository<User, String> {

    suspend fun findOne(id: String): User

    fun findByFirstname(firstname: String): Flow<User>
}

Original pull request: #415.
2020-01-16 11:28:33 +01:00
Oliver Drotbohm
1d2b81bec8 DATACMNS-1639 - Introduce InstantiationAwarePropertyAccessor.
We now ship and use a PropertyAccessor implementation by default that will fall back to use the persistence constructor and creating a new instance to "set" a property. This allows completely immutable types, ommitting previously needed wither methods, e.g. to populate automatically generated identifier values.

This is implemented by using the EntityInstantiator available and a ParameterValueProvider that returns the value of the properties of the current instance but replacing the one for the value to be set. This requires moving EntityInstantiators, the EntityInstantiator SPI as well as all existing implementations (reflective, class generating and the Kotlin one) into the mapping.model package. Legacy instances stay around in deprecated form to avoid breaking existing clients (other store modules as well as user implementations of EntityInstantiator).

The newly introduced implementations stay package protected as their sole users are now colocated in the same package. Access from the legacy types is handled via InternalEntityInstantiatorFactory, which is introduced in deprecated from for removal alongside the actual deprecations.
2020-01-16 11:20:17 +01:00
Shaun Chyxion
09a7de07ad DATACMNS-1651 - Fix typo in Javadoc.
Correct comment "subject" -> "predicate"

Original pull request: #427.
2020-01-16 11:06:47 +01:00
Oliver Drotbohm
1406af8f71 DATACMNS-1647 - Switched to use factory methods of RepresentationModel types. 2020-01-14 14:49:45 +01:00
Mark Paluch
b69141ac17 DATACMNS-1645 - Add search prefix for part tree queries.
We're adding search as prefix for derived repository query methods to improve readability when a Spring Data module is integrated with a search engine. Now it's possible to create a `search…By…` query like `searchByFirstname`.
2020-01-13 15:36:29 +01:00
Greg Turnquist
4adef63610 DATACMNS-990 - Enable builds on JDK 11+. 2020-01-09 09:47:52 -06:00
Mark Paluch
eed7658ce5 DATACMNS-1643 - Update copyright years to 2020. 2020-01-07 08:32:25 +01:00
Oliver Drotbohm
664e661783 DATACMNS-1593, DATACMNS-1635 - Overhauled null handling in QuerydslPredicateArgumentResolver.
QuerydslPredicateArgumentResolver now properly handles predicate lookups that result in null values. The semantics of a handler method parameter of type of Querydsl's Predicate have been tightened to always see a non-null Predicate by default. Users that want to handle the absence of predicates explicitly can opt into seeing null by annotating the parameter with @Nullable or use Optional<Predicate>.

QuerydslPredicateBuilder now consistently returns null in case the original parameter map is entirely empty or consists of only keys with empty value arrays as empty form submissions do. This partially reverts the work of DATACMNS-1168, which moved into the direction of returning a default Predicate value for empty maps in the first place. That however prevents us from producing empty Optionals.

Related tickets: DATACMNS-1168.
2019-12-10 14:52:06 +01:00
Oliver Drotbohm
eff3850806 DATACMNS-1620 - Polishing.
Moved off deprecated API for annotation introspection. Move application of primary flag for bean definitions from RepositoryConfigurationDelegate to RepositoryBeanDefinitionBuilder.
2019-12-09 17:37:44 +01:00
Oliver Drotbohm
8fe3b9983a DATACMNS-1620 - Repository bean definitions now contain human readable resource descriptions.
We now expose human readable resource descriptions based on RepositoryConfiguration and RepositoryConfigurationSource. Spring Boot uses those to describe problematic bean definitions in case it detects errors in the application setup.
2019-12-09 17:37:44 +01:00
Mark Paluch
0cf58e623b DATACMNS-1629 - Log module name in RepositoryConfigurationDelegate during repository scanning.
We now log the module name during repository scanning to indicate the used module and to avoid confusion about duplicate initialization when a single module is used that supports both, imperative and reactive repositories.
2019-11-29 10:45:29 +01:00
Mark Paluch
e9a0ed7123 DATACMNS-1592 - Use Lombok's With and move off deprecated Wither.
We now migrate off Lombok's `@Wither` in favor of `@With`.
2019-11-26 13:55:23 +01:00
Johnny Lim
c1ba1faaa0 DATACMNS-1603 - Fix typo.
Original pull request: #422.
2019-11-26 13:37:30 +01:00
Mark Paluch
e3d6c31929 DATACMNS-1603 - Improve log message wording. 2019-11-26 13:35:41 +01:00
Oliver Drotbohm
6ce19956ab DATACMNS-1613 - Fixed Chunk.getSize() for usage with an unpaged Pageable.
We now return the content length as size of a Chunk if no Pageable has been used to create a Chunk. This makes the usage of a Chunk without an explicit Pageable work just like it was requested with the size of the given content.
2019-11-13 12:49:19 +01:00
Oliver Drotbohm
ced3dde2a4 DATACMNS-1609, DATACMNS-1438 - Skip collection path segments for auditing properties.
We now skip PersistentPropertyPath instances pointing to auditing properties for which the path contains a collection or map path segment as the PersistentPropertyAccessor currently cannot handle those. A more extensive fix for that will be put in place for Moore but requires more extensive API changes which we don't want to ship in a Lovelace maintenance release.

Related tickets: DATACMNS-1461.
2019-11-11 10:45:18 +01:00
Oliver Drotbohm
e28a78ee8e DATACMNS-1609, DATACMNS-1461 - Polishing. 2019-11-11 10:45:14 +01:00
Oliver Drotbohm
71a42664c2 DATACMNS-1609, DATACMNS-1461 - Handle null intermediates in setting auditing property paths.
We now catch the MappingException produced by trying to set auditing property paths containing null intermediate segments and ignore those. A less expensive (non-Exception-based) approach is going to be introduced for Moore as it requires API changes to the property path setting APIs.

Related tickets: DATACMNS-1438.
2019-11-11 10:45:08 +01:00
Oliver Drotbohm
9e4d490137 DATACMNS-1602 - Avoid attempts to recreate the same property accessor class.
PropertyAccessorClassGenerator now tries to look up the class to be generated first to potentially reuse an already existing one and avoid the recreation and registration of a same class which would trigger a Linkage error as a classloader cannot hold two classes with the same name.

The root of the problem is in the fact that the accessor instances are held in per instance caches in EntityInstantiators, so that multiple of those might try to create the same accessor class for a given domain type.
2019-10-30 15:04:12 +01:00
Mark Paluch
5542474ed2 DATACMNS-1601 - Polishing.
Document throws on save(…). Align documentation for reactive repositories.

Original pull request: #412.
2019-10-30 11:17:47 +01:00
Jens Schauder
345df4e393 DATACMNS-1601 - Improving the JavaDoc of the CrudRepository.
Clarifying expectations and guarantees or lack thereof.

Original pull request: #412.
2019-10-30 11:07:36 +01:00
Mark Paluch
cace881a13 DATACMNS-1598 - Polishing.
Add unit tests to back change. Guard invocations against null dereference.
Join assertions.

Original pull request: #409.
2019-10-28 08:54:17 +01:00
Wilds
36b95d39ce DATACMNS-1598 - Fix interface projection returning EnumSet.
EnumSet's are now constructed with a proper component type.

Original pull request: #409.
2019-10-28 08:48:58 +01:00
Mark Paluch
ac0633ed82 DATACMNS-1596 - Polishing.
Fix Javadoc method reference.

Original pull request: #411.
2019-10-24 15:00:04 +02:00
Oliver Drotbohm
8bb87a1749 DATACMNS-1596 - Modules not exposing identifying annotations do not claim repository interfaces anymore.
Previously, a module not exposing any entity identifying annotations would have claimed a repository definition and potentially overrode the bean definition of another store that was the proper claim in the first place. We have now changed this to abstain from a claim of the interface.

We' also tweaked the log output in the following cases:

1. If the module neither returns an identifying type nor entity identifying annotations, we now log a warning that a module does not support a multi-module setup and answer all assignment requests with false.

2. The info level warning indicating an interface has been dropped now reports which annotations or interface base types to use.

Original pull request: #411.
Related tickets: spring-projects/spring-boot#18721
2019-10-24 14:39:48 +02:00
Mark Paluch
373eccda8a DATACMNS-1591 - Polishing.
Add since tags. Reorder methods. Use method references where possible.

Original pull request: #410.
2019-10-16 12:07:13 +02:00
Oliver Drotbohm
529d7a9d47 DATACMNS-1591 - Polishing.
Whitespace.

Original pull request: #410.
2019-10-16 12:05:07 +02:00
Oliver Drotbohm
efccf6d480 DATACMNS-1591 - @Primary is now considered on repository interfaces.
We now elevate the primary annotation from the scanned repository bean definition to the one created for the repository factory. This previously got lost as the former is hidden behind the RepositoryConfiguration interface that previously didn't expose the primary nature of the underlying bean definition.

Original pull request: #410.
2019-10-16 12:04:59 +02:00
Mark Paluch
dbc6810fc3 DATACMNS-1211 - Add ReactivePageableHandlerMethodArgumentResolver.
Add ReactivePageableHandlerMethodArgumentResolver and extract shared code from imperative PageableHandlerMethodArgumentResolver into PageableHandlerMethodArgumentResolverSupport.

Original pull request: #264.
2019-09-26 16:43:58 +02:00
Mark Paluch
48daa4c4b1 DATACMNS-1211 - Add ReactiveSortHandlerMethodArgumentResolver.
Add ReactiveSortHandlerMethodArgumentResolver and extract shared code from imperative SortHandlerMethodArgumentResolver into SortHandlerMethodArgumentResolverSupport.

Original pull request: #264.
2019-09-26 16:43:50 +02:00
Oliver Drotbohm
d1d5fa085d DATACMNS-1583 - Introduced QPageRequest.of(…) factory methods.
These methods are introduced for consistency with PageRequest. Constructors have been deprecated fro removal in 2.2.
2019-09-25 13:58:39 +02:00