Commit Graph

312 Commits

Author SHA1 Message Date
Mark Paluch
b55f098b43 Remove references to ClassTypeInformation from TypeInformation.
Closes #2703
2022-10-06 16:20:22 +02:00
Jens Schauder
db34b52b89 Remove non Javadoc comments.
Closes #2699
2022-10-05 15:39:44 +02:00
Mark Paluch
6a0a404ef2 Fall back to canonical constructor in constructor resolution when using Java Records.
We now fall back to the canonical constructor of records when we cannot disambiguate which constructor to use.

Also, reflect the Kotlin persistence creator mechanism.

Closes #2625
Original pull request: #2694.
2022-10-04 15:05:15 +02:00
Christoph Strobl
0262380d29 Add native image runtime hints.
We provide an initial set of runtime hints required to spin up data repositories on GraalVM native image.
Additionally we skip synthetic types during type inspection.

Original Pull Request: #2624
2022-07-04 14:22:04 +02:00
Mark Paluch
35dbda7144 Polishing.
Add assertions, refine Javadoc.

Original pull request: #2635.
See #2634.
2022-06-14 10:01:49 +02:00
Christoph Strobl
02bf260d6d Introduce ManagedTypes.
We now provide an abstraction to describe a collection of entity types that can be provided to the mapping context as improvement over `Set<Class>` for easier context setup.

Original pull request: #2635.
Closes #2634.
2022-06-14 10:01:49 +02:00
Oliver Drotbohm
07342cffb5 Polishing.
Move all primary interaction API into TypeInformation to prepare making all implementations package protected. Adapt all deprecated API usage in Spring Data Commons to the new one.

Benchmark results look as follows:

2.7
                                                                                                Mode  Cnt          Score          Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   81982861,995 ±   269948,368  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   18472975,689 ±   161234,912  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4029631,568 ±    18990,863  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   11495517,933 ±   209269,454  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   11192152,036 ±   249721,563  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   18835101,279 ±    81895,338  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   16309896,939 ±    80376,406  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   15471691,537 ±    52426,121  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   12080159,283 ±    49922,326  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   12166160,066 ±   173876,051  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   13548906,437 ±   485944,886  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   16457347,670 ±    64170,567  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   14115878,948 ±    57491,268  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15137904,257 ±    51148,726  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  146820080,682 ± 13254238,407  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   55420351,827 ±  1888634,217  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  193934847,273 ±   442867,276  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  192032977,366 ±  4300192,665  ops/s

3.0 – Before this change
                                                                                                Mode  Cnt          Score         Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   81124249,138 ±  174095,495  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   18685936,220 ±  243939,063  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4125709,048 ±   17615,890  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   12277837,989 ±   96973,908  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   12419978,391 ±   45780,658  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   18744593,010 ±   71655,735  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   16497286,465 ±   41150,718  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   15639640,554 ±   69758,391  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   11715068,503 ±   66085,900  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   12159285,083 ±   58171,950  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   13711647,512 ±   66496,271  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   16287057,838 ±   54826,532  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   13847665,634 ±  127834,292  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15099300,270 ±   89030,403  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  151893972,774 ±  494555,250  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   55869432,892 ±  389099,409  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  192661151,755 ± 1075079,924  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  192315554,269 ± 3061160,314  ops/s

3.0 – After this change
                                                                                                Mode  Cnt          Score         Error  Units
TypicalEntityReaderBenchmark.hasReadTarget                                                     thrpt   10   82650245,236 ±  321384,577  ops/s
TypicalEntityReaderBenchmark.kotlinDataClass                                                   thrpt   10   21304680,430 ±  396764,834  ops/s
TypicalEntityReaderBenchmark.kotlinDataClassWithDefaulting                                     thrpt   10    4422187,275 ±   35088,721  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndField                          thrpt   10   13345503,496 ±  180490,423  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorAndProperty                       thrpt   10   13911653,366 ±  266028,886  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedConstructorArgsCreation                      thrpt   10   21192316,261 ±  356534,938  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedFieldAccess                                  thrpt   10   17533419,173 ±   49226,408  ops/s
TypicalEntityReaderBenchmark.simpleEntityGeneratedPropertyAccess                               thrpt   10   17393382,078 ±  114774,442  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndField                         thrpt   10   12867285,952 ±   62870,980  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorAndProperty                      thrpt   10   13208453,130 ±  272795,070  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveConstructorArgsCreation                     thrpt   10   14998467,714 ±   84265,782  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectiveFieldAccess                                 thrpt   10   17365982,413 ±  115287,403  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccess                              thrpt   10   15503841,949 ±  123631,592  ops/s
TypicalEntityReaderBenchmark.simpleEntityReflectivePropertyAccessWithCustomConversionRegistry  thrpt   10   15716685,449 ±   64686,646  ops/s

DefaultTypeMapperBenchmark.readTyped                                                           thrpt   10  154433835,941 ± 1391455,835  ops/s
DefaultTypeMapperBenchmark.readTypedWithBaseType                                               thrpt   10   77919886,633 ±  438244,738  ops/s
DefaultTypeMapperBenchmark.readUntyped                                                         thrpt   10  194435210,217 ±  936274,571  ops/s
DefaultTypeMapperBenchmark.readUntypedWithBaseType                                             thrpt   10  193768718,043 ±  475103,167  ops/s

Original pull request: #2572.
Related ticket: #2312.
2022-06-10 20:50:24 +02:00
John Blum
8721ab4170 Polish for Exception message punctuation cleanup.
Closes #2603.
2022-06-07 13:04:18 -07:00
jo
6a23723f07 Remove punctuation in all exception messages.
Closes #2603.
2022-06-07 12:53:13 -07:00
Oliver Drotbohm
1792cd8f45 Fix PersistentEntity lookup in AbstractMappingContext.hasPersistentEntity(…)
Looking up a PersistentEntity via ….getPersistentEntity(…) applies some massaging of the given type as it could be a proxy type created for a user type. That wrangling was not applied in ….hasPersistentEntity(…) which resulted in a call to that method with a proxy type yielding false although it shouldn't if we already have a PersistentEntity available for the corresponding user type.

We now explicitly lookup the entity by original type and, if it's not the user type itself, try to look up the entity for the latter.

Fixes #2589.
2022-04-08 11:39:14 +02:00
Mark Paluch
e25fb0b16a Remove package cycle between mapping and convert.
Remove accessor methods to obtain annotated converters on PersistentProperty.

Closes #2576
2022-04-05 10:34:35 +02:00
Mark Paluch
0e5e869cbf Reintroduce explicit local variable types.
We now reinstate local variable types instead of var as general var usage removes contextual detail that cannot be omitted generally.

See #2465
2022-03-28 08:55:29 +02:00
Mark Paluch
f5ee277a6e Gracefully skip non-assignable lambda callbacks on Java 18.
We now consider IllegalArgumentException as marker for incompatible lambda payload that was introduced with Java 18's reflection rewrite that uses method handles internally.

Closes #2583
2022-03-23 10:46:09 +01:00
Mark Paluch
dda102ad7f Polishing.
Increase visibility of converter builders.

Refine generics naming towards DV/SV instead of A/B to easier identify store-native values and domains-specific values in the API. Refactor PropertyValueConversions.hasValueConverter into a non-default method.

Tweak documentation.

See #1484
Original pull request: #2566.
2022-03-18 14:54:47 +01:00
Christoph Strobl
228431534f Refine API and property-converter documentation.
See #1484
Original pull request: #2566.
2022-03-18 14:54:37 +01:00
Oliver Drotbohm
e7292279bf Fluent registration API for PropertyValueConverters.
Introduce a builder API to register PropertyValueConverters using simple (Bi)Functions. Additional methods on ValueConversionContext to enable advanced use cases in converter implementation. Tweak generics of VCC to be able to expose store-specific PersistentProperty implementations via the context.

See #1484
Original pull request: #2566.
2022-03-18 14:54:17 +01:00
Christoph Strobl
caf49ad739 Add support for property-specific converters.
Closes #1484
Original pull request: #2566.
2022-03-18 14:54:15 +01:00
Oliver Drotbohm
92d8de08e4 Simpler check to avoid primitive conversion in ConvertingPropertyAccessor.
We now use Spring's ClassUtils.isAssignable(…) directly. Unit tests to verify that conversion is skipped for primitive / boxed scenarios.

See #2546.
2022-02-17 14:36:45 +01:00
Christoph Strobl
01291619f4 Update copyright year to 2022.
See: #2552
2022-02-17 12:46:14 +01:00
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