Commit Graph

1170 Commits

Author SHA1 Message Date
Mark Paluch
788457c901 Migrate off SLF4J to Spring JCL.
Closes #2496
2021-11-16 10:48:56 +01:00
Mark Paluch
55b83dfa83 Refine documentation for PageableExecutionUtils.
Closes #2492
2021-11-09 14:48:42 +01:00
Oliver Drotbohm
c866b42025 Polishing.
A few further tweaks: ClassTypeInformation now never unwraps the user type to consistently work with the type originally presented in the lookup. That allows us to get rid of the custom equals(…)/hashCode() methods and removes the need to deal with original and user type in the same CTI instance.

The augmented caching of PersistentEntities in AbstractMappingContext now primarily happens in doAddPersistentEntity(…). We still need to implement a cache manipulation for the case that a user type has caused the creation of a PersistentEntity first and we see a lookup for the proxy type later. Before actually processing the TypeInformation we now try to lookup an already existing PersistentEntity for the user type and augment the cache if one was found.

See #2485
Original pull request: #2486.
2021-10-27 12:19:15 +02:00
Mark Paluch
ac9d11638c Polishing.
Remove isProxyTypeInformation from TypeInformation. Use computeIfAbsent to fall back to user type information when attempting to add a entity to the MappingContext.

See #2485
Original pull request: #2486.
2021-10-27 09:19:36 +02:00
Christoph Strobl
c30f3fc8af Create PersistentEntities only for user class in case of proxy instance.
This commit makes sure to only create a PersistentEntity for an actual user type. Therefore ClassTypeInformation now considers the given type and not only the user one for both equals and hashcode. This makes sure we can distinguish TypeInformation for a proxy from the one of a user class.
The AbstractMapping context will take care of unpacking proxied types and registering the created entity for both the user as well as the proxy type information.
Prior to this commit build time generated proxy instances would have been able to pollute the context depending on the order they had been served by the initial entity set.

Closes #2485
Original pull request: #2486.
2021-10-27 09:19:36 +02:00
Mark Paluch
69397a11b2 Polishing.
Reduce test element visibility, remove unused constant.

See #2472
2021-10-19 14:31:20 +02:00
Mark Paluch
7c1886201c Consider nested property paths containing a number.
PropertyPath now considers nested property paths (userLastname2 -> user.lastname2) that contain or end with a number.

Closes #2472
2021-10-19 14:31:20 +02:00
alikilickaya
dd8a8083a5 Fix Javadoc in QueryByExampleExecutor.
Closes #2480
2021-10-13 14:16:35 +02:00
Pavel Gnusin
c383024312 Look up bean merged bean definitions in Repositories.
We now look up bean definitions for repositories using BeanFactory.getMergedBeanDefinition(…) to consider parent-child relationships across application contexts.

As we iterate through bean definitions considering ancestors we need to allow parent bean definitions. Previously, we obtained the bean definition from the child context and since the bean was inherited from the parent, the child context cannot provide a bean definition.

Closes #2383
Original pull request: #2384.
2021-10-12 09:38:54 +02:00
Mark Paluch
4e528a590a Allow reuse of ProjectionFactory from RepositoryFactorySupport.
Closes #2441
2021-10-11 11:06:52 +02:00
Mark Paluch
511181193e Add FluentQuery support to QueryByExampleExecutor and ReactiveQueryByExampleExecutor.
FluentQuery allows extending a query specification initially defined by a Example probe or a Querydsl Predicate and fetching the actual result through a functional programming model:

interface PersonRepository extends QuerydslPredicateExecutor<Person> {
  <S extends T, R> R findBy(Predicate predicate, Function<FluentQuery.FetchableFluentQuery<S>, R> queryFunction);
}

PersonRepository repo = …;

List<PersonProjection> result = repo.findBy(QPerson.person.name.eq("Walter"), q -> q.sort(Sort.by("lastname")).as(PersonProjection.class).all());

Closes: #2228
Original pull request: #2421.
2021-10-08 09:17:38 +02:00
Mark Paluch
f1f08933da Polishing.
Add since and author tags. Add ticket references to tests. Reformat code.

See #2471
2021-10-06 10:13:00 +02:00
hantsy
d18275770c Add Smallrye Mutiny support.
Closes #2471
2021-10-06 09:55:20 +02:00
Mark Paluch
82fd3cac27 Deprecate support for RxJava 2.
Closes #2470
2021-09-27 14:04:36 +02:00
Mark Paluch
9fbf39154f Fix Javadoc.
Fix invalid links. Replace Javadoc links to JSR-305 with code annotations.

Replace self-enclosing tags with simple ones.

See #2423
2021-09-21 11:11:30 +02:00
Mark Paluch
bb3898add3 Consider property path root in QuerydslBindings.
We now consider a qualified property path when registering and querying `QuerydslBindings` to ensure that paths matching various domain types do not accidentally get applied for a different type than they were registered for.
Previously, a binding for `Address.description` would be also applied to `User.description` as only the property path `description` was considered when looking up bindings.

Closes: #2418
Original Pull Request: #2422
2021-09-14 16:06:12 +02:00
Mark Paluch
27d4918ad5 Publish delete events by repository methods deleteInBatch and deleteAllInBatch methods.
We now publish events from deleteInBatch and deleteAllInBatch methods to consider well-known repository methods.
We also now prevent event publication if the method argument is not an instance of the domain type.

Closes: #2448.
2021-09-14 10:08:54 +02:00
Mark Paluch
f4805503c8 Reuse generated entity instantiators from ClassGeneratingEntityInstantiator instances.
We now reuse generated ObjectInstantiator classes instead of attempting to redefine classes with the same name. Redefinition leads to LinkageError and thus to the use of reflection-based instantiators and an increased allocation rate due to the failed attempt of class redeclaration.

Closes: #2446.
2021-09-09 15:18:30 +02:00
Mark Paluch
242a71ca56 Avoid Iterator allocations when calling Sort.isSorted().
Closes #2445
2021-09-07 16:07:24 +02:00
Oliver Drotbohm
c7c2df6cd9 Support for jMolecules' @Identity annotation.
Fixes #2438
Original pull request: #2439.
2021-09-07 09:12:51 +02:00
Oliver Drotbohm
3c887f6319 Avoid reflection in SpringDataWebConfiguration.
We now use an explicit lookup via the application context to consume PageableHandlerMethodArgumentResolverCustomizer and SortHandlerMethodArgumentResolverCustomizer rather than autowiring those into a field.

Fixes #2440.
2021-08-26 16:13:44 +02:00
Oliver Drotbohm
fbe513446d 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:06:56 +02:00
Mark Paluch
5fd8687506 Polishing.
Extract adding the actual entity to the MappingContext into its own method along with error handling spanning the entire entity initialization process.

See #2329
Original pull request: #2367.
2021-07-20 10:17:22 +02:00
Greg L. Turnquist
2511b1f1d6 Remove PersistentEntity from MappingContext upon mapping metadata initialization errors.
When an error happens inside the AbstractMappingContext, the caching sometimes gets corrupted. That's because some exceptions are caught, others are not. Instead, the error handling that clears out the cache needs to be shifted up one level, resulting in a simpler code block.

Closes #2329
Original pull request: #2367.
2021-07-20 10:16:30 +02:00
Mark Paluch
db8431ee41 Polishing.
Un-deprecate constructor. Rearrange method arguments to match parameter significance. Reformat code, replace space indents with tabs.

Original pull request: #2403.
2021-07-13 14:13:44 +02:00
sokomishalov
f91901387f Accept JsonProvider upon JsonProjectingMethodInterceptorFactory creation.
We now configure explicitly the JsonProvider that is used by JSONPath through JsonProjectingMethodInterceptorFactory to avoid misconfiguration due to JSONPath defaulting attempts. Accepting JsonProvider allows for improved flexibility during configuration.

Closes #2403
2021-07-13 14:11:48 +02:00
Mark Paluch
9ca1c7e157 Refine ClassGeneratingEntityInstantiator deprecation note.
Closes #2400
2021-07-13 10:35:16 +02:00
Christoph Strobl
b3ae0f7b0b Polishing.
Update documentation to match method signature.

Original Pull Request: #2410
2021-07-13 07:51:06 +02:00
Oliver Drotbohm
d3cd1ab60a Persistent entity type detection now starts with the association target type if available.
This causes us to inspect the most concrete type we can find from a property declaration that might be overridden using an annotation.

Closes: #2409
Original Pull Request: #2410
2021-07-13 07:48:28 +02:00
Oliver Drotbohm
e565c11dcc Consolidate names of methods that provide access to TypeInformation and Class on PersistentProperty.
We now name methods returning a TypeInformation<?> …TypeInformation() and ones that return Class<?> …Type(). In case of both flavors provided, overloads should move to the TypeInformation-based variant as the other one simply resolves ….getType() on the returned value.

Closes: #2408
Original Pull Request: #2410
2021-07-13 07:47:53 +02:00
David Becker
95e115b357 Fix EvaluationContextExtension filter fall-through in ReactiveExtensionAwareEvaluationContextProvider.
Using JpaEvaluationContextExtension with reactive infrastructure in place, ReactiveExtensionAwareEvaluationContextProvider can lead to IllegalStateException if the desired extension doesn't match the predicate instead of being silently dropped.

Closes #2392
Original pull request: #2393.
2021-07-12 15:47:43 +02:00
Stephane Nicoll
8262e21c1a Polishing.
A public bean method that returns a private type is unusual and prevents the processing of such bean in reflection-free use cases. There was also an unnecessary qualifier in the implementation.

Closes #2399
2021-07-12 15:18:35 +02:00
Oliver Drotbohm
b3b590dcf0 Unify entity type detection.
Unified the calculations made for entityTypeInformation and entityTypes in AbstractPersistentProperty. This avoids both calculations getting out of sync. Also we avoid premature calculation abortions if SimpleTypeHolder.isSimpleType(…) returns true for the raw property type. The latter has caused issues for collection properties in Spring Data KeyValue which considers everything in java.util a simple type.

Related ticket: #2390.
2021-07-09 11:10:34 +02:00
Mark Paluch
ab74551928 Polishing.
Reduce TypeDiscoverer.isNullableWrapper method visibility to private to avoid exposure in preparation for wider value type support.

Original pull request: #2394.
See #2390.
2021-07-08 11:49:56 +02:00
Christoph Strobl
3277467b74 Resolve all persistent entities for a persistent property.
Original pull request: #2394.
Closes #2390.
2021-07-08 11:49:36 +02:00
Christoph Strobl
1f77786d89 Don't create PersistentEntity for Nullable wrapper type.
Original pull request: #2394.
Closes #2390.
2021-07-08 11:49:25 +02:00
Mark Paluch
26c2db248b Polishing.
Fix Javadoc formatting. Consistently mention proxy class unwrapping.

Original pull request: #2406.
2021-07-07 14:52:03 +02:00
Oliver Drotbohm
27eac58691 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:44:52 +02:00
Mark Paluch
394187a03b Revise QuerydslPredicateBuilder nullability behavior.
We now no longer return a null Predicate from QuerydslPredicateBuilder.getPredicate(…) if the input values are empty or if the constraints are empty. Instead, we return an empty BooleanBuilder instance to avoid null handling on the calling side.

HandlerMethodArgumentsResolvers for QuerydslBindings retain their null/Optional.empty semantics.

Closes #2396
2021-06-29 10:12:34 +02:00
Mark Paluch
c24ba262ca Polishing.
Use Spring's nullability annotations where used as part of API nullability indicators.

See #2385
2021-06-17 09:03:00 +02:00
Mark Paluch
9242b2c7b2 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:53 +02:00
Mark Paluch
ac9b127d9c 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:51 +02:00
Mark Paluch
0d4fb6073d Introduce instantiateClass as replacement for RepositoryFactorySupport.getTargetRepositoryViaReflection.
getTargetRepositoryViaReflection accepting Class has a misleading name as it lets assume that the returned instance is a repository. In fact, this method looks up a matching constructor for the given arguments and creates an instance.

Closes #2361
2021-04-27 10:32:15 +02:00
Mark Paluch
c94fe6d2e0 Limit BeanWrapper's KotlinCopyUtil to Kotlin Data classes.
Previously, we tried to invoke the copy(…) method on all Kotlin classes whereas the copy(…) method is only specific to Kotlin data classes.

Original pull request: #390.
Closes #2358.
2021-04-21 09:29:37 +02:00
Mark Paluch
40222d6d8c Polishing.
Skip shadowed properties that are not assignable to their shadowing type.

Extend tests. Document property overrides.

Original pull request: #390.
See #1911.
2021-04-21 09:29:37 +02:00
Christoph Strobl
85578b5cb1 Ignore override properties when creating PersistentEntity.
Original pull request: #390.
Closes #1911.
2021-04-21 09:29:37 +02:00
Oliver Drotbohm
c643d2d90f AbstractPersistentProperty now considers association target type for ….getPersistentEntityTypes().
Prior to this commit, the lookup of types to be added as persistent entities for a given PersistentProperty used the actual property type which did not consider the association target type at all. Removed the usage of Optional for the entity type information and switched to use TypeInformation for the raw association target type so that it can be considered in ….getActualType().
2021-04-07 15:31:43 +02:00
Mark Paluch
8adfe47efa Improve ClassGeneratingEntityInstantiator error message if the to be instantiated type is abstract.
We now throw MappingInstantiationException with a nested BeanInstantiationException in alignment to ReflectionEntityInstantiator when attempting to create a new instance of an abstract class.

Closes #2348.
2021-04-06 14:15:16 +02:00
Mark Paluch
d27ac79771 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:39:21 +02:00
Oliver Drotbohm
23ebf3164f Support for association target type detection for jMolecules.
We now detect the component type of jMolecules' Association as association target type in AbstractPersistentProperty. AnnotationBasedPersistentProperty keeps the lookup of the explicit @Reference around but falls back to the Association analysis for that.

@Reference is now only considered by AnnotationBasedPersistentProperty. It was previously also (erroneously) considered by AbstractPersistentProperty.

It was also changed to return `null` in case no association target type could be looked up instead of returning the sole property's type in case that is an entity. This was done to satisfy the behavior documented on the interface but also to avoid the call to isEntity() during the calculation which might use association information in turn and thus lead to a stack overflow. Reworded the contract of PersistentProperty.getAssociationTargetType() to emphasize the symmetry with ….isAssociation() in implementation classes.

Closes: #2344.
2021-03-31 15:07:25 +02:00