Commit Graph

789 Commits

Author SHA1 Message Date
Mark Paluch
d871bb6066 Remove tests that check for absence of parameter names.
Closes #2444
2021-09-07 09:09:23 +02:00
Oliver Drotbohm
6aee21d2ec StreamUtils.zip(…) now treats infinite streams correctly.
When an infinite Stream was handed into StreamUtils.zip(…) as first argument, the resulting stream was infinite, too, while inverting the argument order was limiting the resulting stream to the length of the finite one. This is now fixed by actually evaluating whether we can advance on both of the streams and shortcutting the process if that is not possible on either of the streams, limiting the processing of the overall Stream to the shorter of the two as already advertised in the Javadoc.

Fixes #2426.
2021-08-09 17:04:11 +02:00
Mark Paluch
5be698683b Polishing.
Add unit tests.

See #2392
Original pull request: #2393.
2021-07-12 15:47:39 +02:00
Oliver Drotbohm
629a519550 Repositories now allows lookup of parent repositories for sub-types.
When inheritance is used for aggregates, lookups of the repository for a Child aggregate instance have so far failed to return a repository registered for the Parent. Client code had to consider that scenario explicitly.

This commit introduces an additional lookup step in case we cannot find a repository for an aggregate type immediately. In this case, we then check for assignability of any of the known aggregate types we have registered repositories for and the type requested. I.e. for a request for the repository of Child, a repository, explicitly registered to manage Child instances would still be used. In the sole presence of a repository managing Parent instances, that would be returned for the request for Child, too.

Original pull request: #2406.
2021-07-07 14:45:48 +02:00
Mark Paluch
b469b5d4c7 Allow combining Sort and TypedSort using Sort.and(…).
We now retain properly the collection of orders by using accessor methods instead of relying on using the orders field. TypedSort orders are not using the orders field, instead they iterate over recorded persistent property paths.

Closes #2103
Original pull request: #2377.
2021-06-10 15:01:43 +02:00
Mark Paluch
2bb21181e8 Obtain merged annotation for annotation validation.
We now validate declared annotations by pre-processing these through AnnotatedElementUtils to ensure a proper comparison. Previously, we compared annotation in their declared form (AnnotatedElement.getAnnotations()) with merged annotations which could fail due to aliasing effects of merged annotations.

Closes #2368.
2021-05-05 12:05:40 +02:00
Mark Paluch
1f583bab3d Back-off in ResultProcessor if the result object is an instance of the target type.
We now do not attempt to convert the object if it is an instance of the declared target type.

Closes #2347.
2021-04-06 13:37:10 +02:00
Mark Paluch
b6581ebd14 Fix Kotlin copy method assignability check.
We now resolve only the raw class when checking if a primary constructor argument is assignable to method parameters of the synthetic copy method.
Previously we used ResolvableType's assignability check which considered generic type arguments. As the type resolution between the KType and copy method type is not symmetric, the check only succeeded in cases where both types could be resolved to the same type/assignable type. Using projections or Any caused asymmetric resolution and therefor the assignability check returned non-assignable.

Closes #2324.
2021-03-22 10:06:47 +01:00
Mark Paluch
d43d5add66 Polishing.
Use ResolvableType for type assignability check when resolving Type from a KType.

See #2324.
2021-03-12 16:56:53 +01:00
Mark Paluch
eac1105177 Polishing.
Reduce test method visibility.

See #2324.
2021-03-12 11:30:01 +01:00
Mark Paluch
6a5812b3de Use primary copy method for Kotlin data classes.
We now resolve the copy method for Kotlin data classes that match the primary constructor. Previously, copy method resolution could find a secondary copy method as we didn't check for the primary constructor structure (parameter names and types).

Closes #2324.
2021-03-12 11:30:01 +01:00
Mark Paluch
aaf5858f49 Polishing.
Reformat code.

Original pull request: #2314.
Closes: #2313
2021-03-01 10:34:53 +01:00
Christoph Strobl
8f4befff83 Collect constructor type information via Constructor.getParameters().
This commit fixes an issue where we fail to detect all type arguments from a given constructor. calling getGenericParameterTypes in some cases does not include all Types, we now explicitly iterate over the parameters and extract the parameterized type that is used for creating the TypeInformation.

Closes: #2313
Original pull request: #2314.
2021-03-01 10:34:53 +01:00
Jan Zeppenfeld
b615a20a39 Add test for Repositories verifying isPrimary flag.
See #1583.
Original pull request: #465.
2021-02-15 15:58:57 +01:00
Oliver Drotbohm
f83a2edb69 Upgrade to Servlet 4.0 to align with Spring Framework.
Also, tweak test case to avoid to refer to a field in a Spring class but rather use API to access the value. Changes in Spring Framework 5.3.4 require this as the internal structure of AbstractJackson2HttpMessageConverter changed to support custom ObjectMapper instances per type and media type.

Fixes GH-2284.
2021-01-26 22:56:57 +01:00
Oliver Drotbohm
47ee922ac3 Avoid pre-computing base URI in PagedResourceAssemblerArgumentResolver.
We now avoid the pre-computation of the base URI in PagedResourceAssemblerArgumentResolver as the actual assembler will fall back to using the URI of the current request by default anyway. The latter makes sure that request parameters, that are contained in the original requests appear in links created. If a controller wants to deviate from that behavior, they can create a dedicated link themselves and hand that to the assembler explicitly.

Fixes GH-2173, GH-452.
2021-01-26 10:00:57 +01:00
Mark Paluch
42997ac704 Fix constructor resolution for Kotlin classes using unsigned types.
We now leniently skip parameter name resolution for types using unsigned types. The issue is caused by Kotlin's DefaultConstructorMarker that doesn't report a parameter name.

Closes #2215
2021-01-18 13:51:40 +01:00
Jens Schauder
5407e400cc Add JSR310 converters to the converters used for projections.
Similar converters where removed because they clashed with the support for nullable wrappers. This adds them back as dedicated converters that does not clash with conversions for nullable wrappers.

See bd3992dfc5 (diff-96f7084777a2a702d85f5c600e542b10123d6c3332ed3d3f8e329ca7061faab0R55)

Original Pull Request: #479
Closes: #2223
2021-01-13 07:04:37 +01:00
Mark Paluch
75d67ce620 Correctly unwrap nested JSON array projections.
We now check for double-nesting of JSON path evaluation results when the return type is a collection. If the result is double-wrapped and the nested object is a collection then we unwrap it.

Closes #2270
2021-01-12 15:47:11 +01:00
Mark Paluch
81f03e86cc Update copyright year to 2021.
Closes #2268.
2021-01-07 13:42:39 +01:00
Vedran Pavic
f9a776ba1d DATACMNS-1827 - Consider Qualifier meta-annotated Sort method parameters.
Original pull request: #474.
2020-12-01 10:15:27 +01:00
Vedran Pavic
7acadc839c DATACMNS-1827 - Pageable and Sort arguments with empty qualifier value shouldn't be prefixed with delimiter.
Original pull request: #473.
2020-11-11 09:30:15 +01:00
Oliver Drotbohm
5c78c6c56f DATACMNS-1828 - Fix Map component type lookup for custom Map implementations.
Instead of using the first generic type parameter of a parameterized type as Map component type, we now explicitly lookup the super type's Map-specific generics configuration and use its first generic type parameter. The same for collection like types falling back to the parameter type bound to Iterable.
2020-11-05 15:16:23 +01:00
Jens Schauder
6572880412 DATACMNS-1820 - Moves PageabeExecutionUtils to o.s.data.support.
This avoids module cycles when it is used from a template.
The old version is still there, deprecated and delegates to the new version.

Original pull request: #472.
2020-10-28 09:54:54 +01:00
Mark Paluch
d10560f238 DATACMNS-1762 - Reintroduce calls to ReactiveWrapperConverters.supports(…) after decoupling from QueryExecutionConverters.
We now consider reactive wrapper types in all areas that previously relied on QueryExecutionConverters to handle reactive type information correctly. Specifically, we call supports(…) and perform type unwrapping to ensure to detect the correct return type.
2020-09-25 16:25:43 +02:00
Wim Deblauwe
97df0fa899 DATACMNS-1762 - Add tests for projections returning Optional.
Original Pull Request: #459
2020-09-25 08:00:08 +02:00
Mark Paluch
bd3992dfc5 DATACMNS-1762 - Support Optional wrapping for projection getters.
We now support nullable wrappers for projection interfaces. Getters are inspected whether their return type is a supported nullable wrapper. If so, then the value can be wrapped into that type. Null values default in that case to their corresponding empty wrapper representation.

Original Pull Request: #459
2020-09-25 07:59:02 +02:00
Mark Paluch
04f59f1307 DATACMNS-1762 - Extract NullableWrapperConverters from QueryExecutionConverters.
Nullable wrappers such as Java 8 Optional, Guava Optional, Scala Option and Vavr Option are now handled in NullableWrapperConverters and are no longer coupled to QueryExecutionConverters so that this functionality can be reused.

Original Pull Request: #459
2020-09-25 07:58:52 +02:00
Mark Paluch
9ced611ea5 DATACMNS-1762 - Remove ReactiveWrappers support from from QueryExecutionConverters.
ReactiveWrappers doesn't belong in there in the first place so we're removing ReactiveWrappers support from QueryExecutionConverters so ReactiveWrappers is used from parts that need to be reactive-aware.

Original Pull Request: #459
2020-09-25 07:54:21 +02:00
Mark Paluch
b3d0fea061 DATACMNS-1637 - Add default stream() method to CloseableIterator.
CloseableIterator now allows construction of a Stream that is associated with a close hook to release resources after its use.

CloseableIterator<Person> iterator = …;

try (Stream<Person> stream = iterator.stream()) {
	assertThat(stream.count()).isEqualTo(3);
}
2020-09-22 15:47:48 +02:00
Mark Paluch
82cb36f727 DATACMNS-1802 - Add support for suspend repository query methods returning List<T>.
We now support returning List<T> from a suspended repository query method to simplify consumption of collection queries.
2020-09-22 14:44:46 +02:00
Greg L. Turnquist
9d12ac7324 DATACMNS-1736 - Switch away from overrideable methods. 2020-09-15 17:01:19 +02:00
Mark Paluch
168583ea3c DATACMNS-1793 - Polishing.
Clean up invalid imports.
2020-09-09 13:42:01 +02:00
Christoph Strobl
b667dfa779 DATACMNS-1764 - Capture reactive invocation on per subscription basis.
Original Pull Request: #455
2020-08-11 13:53:30 +02:00
Mark Paluch
35a3d3cde9 DATACMNS-1764 - Allow registration of RepositoryFactory customizers.
Original Pull Request: #455
2020-08-11 13:41:38 +02:00
Mark Paluch
e77947f0a5 DATACMNS-1763 - Allow registration of QueryMethod invocation listeners.
We now allow for registering RepositoryMethodInvocationListeners to notify listeners upon repository method invocations (query methods and repository fragments). Listeners are notified upon method completion reporting the repository interface, the invoked methods, duration, outcome and arguments.

Original Pull Request: #455
2020-08-11 13:40:57 +02:00
Mark Paluch
e72470993d DATACMNS-1754 - Polishing.
Revert bean name change so all nested repository interface components (repository bean, fragment bean, legacy custom implementation bean) remain prefixed with their enclosing type name.

Adopt tests. Add test for RepositoryBeanDefinitionRegistrar. Extend documentation.

Original pull request: #460.
2020-08-10 16:33:21 +02:00
Kyrylo Merzlikin
2a44d2394c DATACMNS-1754 - Support implementation lookup for nested repositories and fragments.
Problem: while repository and fragment interfaces are discovered
correctly (provided that considerNestedRepositories=true), their
implementations are not found/registered despite proper class naming.

Cause: DefaultImplementationLookupConfiguration works in such way that
for nested interface (i.e. one whose class name includes name of the
enclosing class) expected implementation class name is built including
that enclosing class name. In the same time actual implementation class
names are always "localized" (i.e. stripped from enclosing class name,
if any) before matching. This makes matching implementation classes
against nested interface impossible.

Solution: when building expected implementation class name, use "local"
interface class name, so that it can match any implementation class that
follows naming convention "SimpleInterfaceName" + "ImplemenetationPostfix".

Original pull request: #460.
2020-08-10 16:29:38 +02:00
Oliver Drotbohm
c99f2c9459 DATACMNS-1296 - PersistentPropertyPathAccessor now properly handles intermediate nulls when setting values.
We now use a dedicated GetOptions instance for the lookup of the parent path in case SetOptions is defined to skip nulls so that the lookup does not fail if the parent path contains a null value.
2020-08-06 08:50:20 +02:00
Mark Paluch
7b26fd199f DATACMNS-1780 - Polishing.
Consistently use MappingException when a required PersistentEntity cannot be obtained.
2020-08-04 15:25:34 +02:00
Christoph Strobl
fd15c099e9 DATACMNS-1780 - PersistentEntities allows in flight metadata creation if the associated mapping context can be identified.
Use a more lenient approach, that allows metadata creation, when looking up persistent entities. This allows eg. a configured AuditingHandler to kick in without having to register an initial entity set in first place.

Original pull request: #462.
2020-08-04 14:39:05 +02:00
Mark Paluch
bb4d621a32 DATACMNS-1779 - Consider kotlin.Unit a simple type.
kotlin.Unit is now considered a simple type to avoid PersistentEntity creation.

ReflectionUtils.isVoid(…) now encapsulates the check so that calling code doesn't need to check if Kotlin is on the class path.
2020-07-31 10:57:56 +02:00
Mark Paluch
e56dcdb461 DATACMNS-1726 - Remove Lombok from compile scope.
Use Java ServiceLoader to identify annotation processors.
2020-07-27 12:10:34 +02:00
Christoph Strobl
fb15a9647d DATACMNS-1108 - Polishing.
Move loop to Set lookup, update Javadoc and remove unused imports.

Original Pull Request: #454
2020-07-22 13:47:00 +02:00
Mark Paluch
0671862ed8 DATACMNS-1108 - Add repository configuration infrastructure.
Add config infrastructure for ReactiveQueryMethodEvaluationContextProvider.

Original Pull Request: #454
2020-07-22 13:45:25 +02:00
Mark Paluch
1c354f6d4e DATACMNS-1108 - Add support for Reactive SpEL Context retrieval.
We now support reactive EvaluationContext retrieval in conjunction with ReactiveEvaluationContextExtensions. Reactive SpEL Context extensions may access Reactor's Context and provide contextual details during SpEL evaluation.

Original Pull Request: #454
2020-07-22 13:43:28 +02:00
Mark Paluch
13c03e9d17 DATACMNS-1772 - Remove SpringDataAnnotationBeanNameGenerator and use BeanNameGenerator directly.
We now invoke BeanNameGenerator directly without additional indirections. Previously, SpringDataAnnotationBeanNameGenerator was calling BeanNameGenerator using null for BeanDefinitionRegistry which caused downstream null dereference.
2020-07-21 14:51:23 +02:00
Christoph Strobl
d4e94109df DATACMNS-1231 - Introduce dedicated Auditor value object.
Original Pull Request: #458
2020-07-17 11:16:43 +02:00
Mark Paluch
d3af4a79e4 DATACMNS-1231 - Add reactive auditing infrastructure.
We now provide a reactive variant for auditing with ReactiveAuditingHandler and ReactiveIsNewAwareAuditingHandler.

Extracted common auditing functionality into AuditingHandlerSupport which serves as base class for AuditingHandler and ReactiveAuditingHandler.

Original Pull Request: #458
2020-07-17 10:14:10 +02:00
Mark Paluch
0c37484b19 DATACMNS-1768 - Polishing.
Reduce test visibility. Remove forEach detour through stream().
2020-07-14 09:50:40 +02:00