Commit Graph

737 Commits

Author SHA1 Message Date
Mark Paluch
80299838b3 DATACMNS-1763 - Expose ReactiveWrapperConverters.doOnSuccess and doOnError callback hooks.
We now provide callback hook operators that allow attaching of a Runnable and Consumer<Throwable> to a reactive wrapper type for participating in terminal signals.
2020-07-06 11:32:45 +02:00
Mark Paluch
8815ff61e9 DATACMNS-1755 - Polishing.
Consistently remove linebreak after license header.

Original pull request: #448.
2020-06-25 11:20:49 +02:00
Phillip Webb
d72ccdacf6 DATACMNS-1755 - Fix malformed copyright headers.
Fix a few copyright headers that had formatting or date issues.

Original pull request: #448.
2020-06-25 11:20:41 +02:00
Phillip Webb
5734cfe878 DATACMNS-1755 - Use specialized assertThat*Exception.
When possible replace `assertThatExceptionOfType` calls with the
equivalent specialized variant.

Original pull request: #448.
2020-06-25 11:20:31 +02:00
Phillip Webb
b225acd22d DATACMNS-1755 - Fix wrong Optional import.
Fix `DefaultRepositoryMetadataUnitTests` to import the `java.util`
version of `Optional` rather than the `com.google` variant.

Original pull request: #448.
2020-06-25 11:20:18 +02:00
Phillip Webb
5c3bb895c7 DATACMNS-1755 - Fix array style.
Update `ClassGeneratingPropertyAccessorFactoryDatatypeTests` to use
the more common `String[] var` array style.

Original pull request: #448.
2020-06-25 11:20:09 +02:00
Mark Paluch
c9a5a19738 DATACMNS-1753 - Polishing.
Check for deferred types in ReactiveWrappers so that ReactiveWrapperConverters remains untouched as wrapper conversion from a reactive type into CompletableFuture is still possible from a ReactiveWrapperConverters perspective.

Original pull request: #450.
2020-06-25 10:46:44 +02:00
Gerrit Meier
558272e57b DATACMNS-1753 - Don't consider CompletableFuture as reactive type.
CompletableFuture use is permitted in imperative repositories so we should not use CompletableFuture as indicator to switch a repository implementation to a reactive one.

Original pull request: #450.
2020-06-25 10:45:53 +02:00
Mark Paluch
2c25a591fb DATACMNS-1750 - Polishing. 2020-06-22 15:27:10 +02:00
Mark Paluch
4bc474d8f4 DATACMNS-1750 - Refrain from inspecting Page contents if first item is null. 2020-06-22 15:27:10 +02:00
Mark Paluch
d3260d3caa DATACMNS-1653 - Add support for RxJava 3.
We now include adapters and registry information for RxJava 3 types.

Original pull request: #444.
2020-06-21 20:05:53 +02:00
Oliver Drotbohm
52154f6986 DATACMNS-1743 - Polishing.
We now avoid identifier conversion in ReflectionrepositoryConverter if not necessary. Reestablish a couple of unit tests for DomainClassConverter that were disabled by accident.
2020-06-16 16:11:26 +02:00
Oliver Drotbohm
aa1c1d4f15 DATACMNS-1743 - Fixed handling of failed aggregate lookup in DomainClassConverter.
We now fall back to null in case the repository lookup for the aggregate results in an absent value rather than returning the source unconverted.
2020-06-16 15:22:06 +02:00
Oliver Drotbohm
f65451d777 DATACMNS-1745 - Polishing.
Made the reference to RepositoryInformation non-nullable from the RepositoryAnnotationTransactionAttributeSource (previously RepositoryInformationPreferring…). Adapted test cases accordingly.
2020-06-16 14:31:15 +02:00
Mark Paluch
a76ed28fe7 DATACMNS-1745 - Refactor CustomAnnotationTransactionAttributeSource to use computeTransactionAttribute template method.
We now no longer duplicate Spring Framework code as AbstractFallbackTransactionAttributeSource exposes computeTransactionAttribute which we can use to override to determine TransactionAttribute from the repository interface.

Renamed CustomAnnotationTransactionAttributeSource to RepositoryInformationPreferringAnnotationTransactionAttributeSource to reflect the nature of our customization.
2020-06-16 14:31:15 +02:00
Oliver Drotbohm
9c50f86061 DATACMNS-1743 - Fix lazy repository lookups in DomainClassConverter.
We now eagerly register DomainClassConverter as converter with the ConversionService in the web setup. We also refrain from explicitly registering the traget converters with the ConversionService as that might trigger a ConcurrentModificationException if called during an iteration over the converters in the first place. As DomainClassConverter registers itself for all ConvertiblePairs and delegates to the individual converters anyway.
2020-06-15 22:10:27 +02:00
Mark Paluch
f93a66fdbc DATACMNS-1744 - Drop the use of the term white list. 2020-06-15 13:45:12 +02:00
Mark Paluch
40e7e89e27 DATACMNS-1738 - Expose method to obtain the repository query method return type.
We now expose RepositoryMetadata.getReturnType(…) to obtain the declared method return type. While pure Java code can rely on Method.getReturnType(), suspended Kotlin methods (Coroutines) require additional lookups. This is because the Kotlin compiler messes around with the return type in the bytecode. It changes the return type to java.lang.Object while synthesizing an additional method argument:

interface MyCoroutineRepository : Repository<Person, String> {
	suspend fun suspendedQueryMethod(): Flow<Person>
}

compiles to

interface MyCoroutineRepository extends Repository<Person, String> {
	Object suspendedQueryMethod(Continuation<Flow<Person>> arg0);
}

Therefore, the triviality of obtaining a return type becomes an inspection of the actual method arguments.

Related ticket: https://jira.spring.io/browse/DATAMONGO-2562
2020-06-09 11:09:31 +02:00
Oliver Drotbohm
210ab249e3 DATACMNS-1734 - Defer initialization of Repositories in DomainClassConverter.
DomainClassConverter now delays the initialization of the Repositories instances used to avoid the premature initialization of repository instances as that can cause deadlocks if the infrastructure backing the repositories is initialized on a separate thread.

Refactored nested converter classes to allow them to be static ones.

Related issues: spring-projects/spring-boot#16230, spring-projects/spring-framework#25131.
Original pull request: #445.
2020-05-29 09:47:21 +02:00
Mark Paluch
fbe51ef1bb DATACMNS-1735 - Polishing.
Use mutated object as guard for synchronization. Copy discovered callbacks to cached callbacks.

Reduce concurrency in unit test to reduce test load. Guard synchronization with timeouts.

Original pull request: #446.
2020-05-27 09:53:52 +02:00
mhyeon-lee
d9969cb7d4 DATACMNS-1735 - Fix ConcurrencyModificationException in EntityCallbackDiscoverer.
We now guard modifications of the cached entity callbacks list with a synchronization block.

Original pull request: #446.
2020-05-27 09:32:24 +02:00
Mark Paluch
7de360cb7b DATACMNS-1676 - Polishing.
Encapsulate field and introduce getter for ConversionService. Add missing Override annotation. Add author tags. Minor cleanups.

Original pull request: #432.
2020-05-12 10:42:01 +02:00
Pavel Horal
f2f7886105 DATACMNS-1676 - Create shared conversion service for AuditableBeanWrapper.
Prevent performance penalty in creating conversion service each time a domain object is being persisted.

Original pull request: #432.
2020-05-12 10:41:27 +02:00
Mark Paluch
152cee7956 DATACMNS-1718 - Migrate tests to JUnit 5. 2020-05-07 11:16:29 +02:00
Mark Paluch
a0abf009a0 DATACMNS-1689 - Resolve suspendable query method result type from Continuation parameter.
Kotlin coroutine methods are compiled returning Object so the original return type gets lost. We resolve the return type from the Continuation parameter that synthetized as last parameter in a coroutine method declaration.
2020-03-19 10:45:27 +01:00
Mark Paluch
f047743cfa DATACMNS-1683 - Rebuild quotation index from rewritten SpEL query.
We now use the correct quotation map that is based on the rewritten SpEL query to detect whether an expression was quoted.
Previously, we used the quotation map from the original query.
After augmenting the query with synthetic parameters, the quotation offset no longer matched the query that ß∑was under inspection and calls to SpelExtractor.isQuoted(…) could report an improper result.

Original pull request: #434.
2020-03-17 11:02:10 +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
09e3bedf74 DATACMNS-1671 - Forward-port unit test.
Add unit test to remain consistent across branches.
2020-02-24 15:40:08 +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
Mark Paluch
781ef48987 DATACMNS-1508 - Guard test to run only on Java 8.
Java 9 introduced different class loaders so it's no longer possible to have a test that covers both setups.
2020-01-16 11:58:19 +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
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
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
9b63646e82 DATACMNS-1630 - Removed custom copy of ShadowingClassLoader in favor of Spring's one. 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
a16c2ce3c4 DATACMNS-1592 - Polishing.
Tweak docs.
2019-11-26 13:56:21 +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
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