Commit Graph

293 Commits

Author SHA1 Message Date
Oliver Drotbohm
21777293cc AbstractPersistentProperty.isMap() now delegates to underlying TypeInformation.
Issue #2549
2022-02-16 15:53:57 +01:00
Oliver Drotbohm
ac9f99fc54 Polishing of annotation model for object creators.
Move to @PersistenceCreator as canonical annotation to explicitly express constructors and methods to be used to create domain object instances from persistence operations. Removed @FactoryMethod as it's not needed anymore. @PersistenceConstructor is now deprecated.

Renamed EntityCreatorMetadata(Support|Discoverer) to InstanceCreatorMetadata(Support|Discoverer) to avoid further manifestation of the notion of an entity in the metamodel as it's not used to only handle entities.

Issue #2476.
2022-02-15 17:26:00 +01:00
Mark Paluch
c4a324e3cf Introduce support to create domain objects via factory methods.
Issue #2476.
2022-02-15 17:04:47 +01:00
Mark Paluch
68bfa9af0e Performance improvements in ReactiveWrappers and ConvertingPropertyAccessor.
We now cache whether types are reactive wrappers and bypass the ConversionService for assignable primitive values.

Closes #2546
2022-02-11 15:22:03 +01:00
Mark Paluch
ce9fcf9eb7 Refine PropertyReferenceException message.
Use single-quotes to indicate which elements belong to the underlying type and which are part of the textual message.

Closes #2395
2022-01-25 14:42:57 +01:00
Jens Schauder
38f50e3da8 Remove Eclipse Non-Javadoc comments.
Closes #2522
2022-01-13 18:51:02 +01:00
Mark Paluch
c735b58607 Migrate code to Java 17 style.
Use var instead of explicit local types where applicable. Use pattern variable instead instanceof and cast. Prefer loops and nullable types over Stream and Optional. Convert classes to records where applicable.

See #2465
2022-01-13 18:49:07 +01:00
Mark Paluch
2618221115 General removal of deprecated API.
See #2466
2022-01-13 18:45:48 +01:00
Mark Paluch
aecdf5001a Remove deprecated EntityInstantiator in convert package in favor of instantiators in mapping.model.
See #2466
2022-01-13 18:45:47 +01:00
Jens Schauder
6cf2634a64 Fixed dependency cycle.
Closes #2514
2021-12-14 15:06:14 +01:00
Christoph Strobl
ecec2e5666 Polishing.
Replace boolean flag with enum, assert open vs. closed projection and update javadoc.

Original Pull Request: #2420
2021-12-13 13:03:18 +01:00
Mark Paluch
a63774e6ec Add support for properties using deep map-in-map/list-in-map nesting.
Original Pull Request: #2420
2021-12-13 13:02:52 +01:00
Mark Paluch
0744580766 Move EntityProjection from inner class to top-level class.
Original Pull Request: #2420
2021-12-13 13:02:25 +01:00
Mark Paluch
b189240aaf Polishing.
Original Pull Request: #2420
2021-12-13 13:01:27 +01:00
Mark Paluch
caa8c6afc5 Refactor PropertyFilterSupport into EntityProjectionIntrospector.
Original Pull Request: #2420
2021-12-13 13:00:59 +01:00
Mark Paluch
9948fefe69 Provide class for inspecting nested projections.
Original Pull Request: #2420
2021-12-13 13:00:20 +01:00
XenoAmess
ca723d11c7 Use AnnotationUtils.findAnnotation(…) instead of AnnotatedElement.isAnnotationPresent(…).
Enable use of meta annotations by leveraging MergedAnnotations.

Closes #2500
2021-12-08 10:15:06 +01:00
Mark Paluch
788457c901 Migrate off SLF4J to Spring JCL.
Closes #2496
2021-11-16 10:48:56 +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
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
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
Oliver Drotbohm
c7c2df6cd9 Support for jMolecules' @Identity annotation.
Fixes #2438
Original pull request: #2439.
2021-09-07 09:12:51 +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
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
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
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
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
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
Mark Paluch
79ed0a75c7 Support @Value meta-annotations and expose MergedAnnotations on PreferredConstructor parameters.
We now support composed annotation that are annotated with `@Value`. we also expose MergedAnnotations through PreferredConstructor.Parameter for further use by store modules that want to inspect constructor argument annotations.

Closes: #2332
Original Pull Request: #2333
2021-03-30 12:06:03 +02:00
Mark Paluch
1eeef23fd9 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 #2336.
2021-03-22 10:06:08 +01:00
Mark Paluch
08cb9e848d Polishing.
Use ResolvableType for type assignability check when resolving Type from a KType.

See #2324.
2021-03-12 16:56:10 +01:00
Mark Paluch
0065c17cca 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:10 +01:00
Oliver Drotbohm
d03bfb877a Introduce PersistentEntity.doWithAll(…).
To let a PropertyHandler operate on all properties *and* the inverse property of associations.

Fixes #2325.
2021-03-11 10:38:44 +01:00
Oliver Drotbohm
6b0292cc66 Support for jMolecules' Association type.
We no recognize properties of type org.jmolecules.ddd.types.Association as associations in our PersistentProperty model.

Also, we now register JMolecules Converter implementations for Association and Identifier in CustomConversions so that they can persisted like their embedded primitive value out of the box.

Fixes #2315.
Original pull request: #2316.
2021-03-01 15:20:26 +01:00
Christoph Strobl
67ee745374 Use NativeDetector.inNativeImage() instead of manual property check.
Closes: #2298
Original pull request: #2299.
Relates to: spring-projects/spring-framework#25795
2021-02-17 09:14:02 +01:00
Christoph Strobl
b51bee7a0b Use contextual information when creating PersistentPropertyPaths.
In oder to preserve contextual information the PersistentPropertyPathFactory now obtains EntityInformation for properties from the MappingContext via their PersistentProperty representation instead of plain the TypeInformation as the former contains more information about the actual type and signatures.

Closes #2293.
Original pull request: #2294.
2021-02-16 10:50:16 +01:00