Commit Graph

1270 Commits

Author SHA1 Message Date
Mark Paluch
51cda9993f Introduce PropertiesBasedNamedQueriesFactoryBean to reduce bean indirections.
We now provide PropertiesBasedNamedQueriesFactoryBean to create PropertiesBasedNamedQueries directly bypassing indirections through PropertiesFactoryBean and PropertiesBasedNamedQueries.

Original Pull Request: #2624
2022-07-04 14:22:05 +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
John Blum
d8118de90f Review, refactor and polish Spring Data AOT infrastructure classes.
* Refactored logic in AOT infrastructure classes.
* Annotated AOT API with Spring's @NonNull and @Nullable annotations.
* Edited Javadoc.
* Introduced PredicateUtils abstract utility class encapsulating common Predicates on types and class members.
* Added comments for review and clarification.

Original Pull Request: #2624
2022-07-04 14:22:04 +02:00
Christoph Strobl
21ff2a7e34 Introduce infrastructure for AOT processing of repository declarations
This commit introduces initial support for framework 6 bases ahead of time processing of data components and adds extension points for module implementations.

See: #2593
Original Pull Request: #2624
2022-07-04 14:22:03 +02:00
Florian Cramer
2a299b2ff2 Use TypeFilterUtils to create TypeFilters.
Original pull request: #2647.
Closes #2481
2022-06-23 13:59:02 +02:00
Oliver Drotbohm
dfc3060ed7 Polishing.
See #2644.
2022-06-20 17:18:45 +02:00
Oliver Drotbohm
75387bb8ae Add RepositoryConfiurationExtension.getModuleIdentifier().
We're now unifying the lookup of a unique identifier for a Spring Data module in the RepositoryConfigurationExtension interface. Previous users of getModulePrefix() in subclasses of RCE should rather call getModuleIdentifier(). Implementations of RCE that previously implemented getModulePrefix() directly should rather switch to implementing getModuleName() and additionally getModuleIdentifier() in case the default implementations derivation of the identifier from the name doesn't produce the results intended.

RepositoryConfigurationExtensionSupport.getDefaultNamedQueryLocation() was changed to rather use the identifier to calculate the name of the named query location instead of the prefix.

Fixes #2644.
2022-06-20 17:18:45 +02:00
Mark Paluch
09558d77d8 Revert exposing getModulePrefix() on RepositoryConfigurationExtension.
This is a breaking change as many modules implement a protected method. We're going to change this later with #2644.

Original pull request: #2635.
See #2634.
2022-06-14 10:01:49 +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
2a1a8f387f Additional refinements in TypeInformation reimplementation.
Slight refinements in TypeDiscoverer.equals(…) / hashCode() that are still not completely valid, are different enough to work for differentiating use cases but not 100% efficient for cache cases. Captured outstanding work in spring-projects/spring-data-commons#2643.

Reimplemented ….repository.query.Parameter.isDynamicProjectParameter(…) to bild on TypeInformation completely and properly unwrapp *all* wrapper types for type comparison.

Related ticket #2312.
2022-06-13 16:04:08 +02:00
Christoph Strobl
18a9f3aa13 Expose RepositoryFragments as infrastructure bean.
We now expose RepositoryFragments as a bean to be referenced when creating the actual repository.

Original Pull Request: #2596
2022-06-13 11:02:51 +02:00
Mark Paluch
712477bf36 Introduce PropertiesBasedNamedQueriesFactoryBean to reduce bean indirections.
We now provide PropertiesBasedNamedQueriesFactoryBean to create PropertiesBasedNamedQueries directly bypassing indirections through PropertiesFactoryBean and PropertiesBasedNamedQueries.

Resolves: #2584
Original Pull Request: #2596
2022-06-13 10:52:34 +02:00
Oliver Drotbohm
0f85f1c720 Prefer explicitly declared generic parameter over Iterable in TypeDiscoverer.getComponentType().
Related ticket: #2312.
2022-06-10 22:12:37 +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
Christoph Strobl
1d6331ccb6 Use ResolvableType to back TypeInformation.
Reworked the implementation of the TypeInformation type hierarchy to be based on Spring's ResolvableType for most of the heavy-lifting.

Original pull request: #2572.
Related ticket: #2312.
2022-06-10 17:36:21 +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
Greg L. Turnquist
e7c3541d39 Extend query method special parameter types to any subclasses.
Spring Data Commons has a hard-coded list of special types than can be included in query methods including Pageable and Sort.

A custom finder with PageRequest, even though it extends Pageable, will fail when it would work fine with a narrowed input. This extends the list using an assignability check.

Related: spring-projects/spring-data-jpa#2013
See #2626.
2022-05-12 17:09:43 +02:00
Oliver Drotbohm
c1012f5ba5 MethodInvocationRecorder now supports traversing primitive properties.
We now return a default value for invocations of methods returning a primitive value to pass the AOP infrastructure's check for compatible values. Before, that barked at the null value returned for the invocation.

Fixes #2612.
2022-05-04 15:10:17 +02:00
Oliver Drotbohm
23ad2f0b3f CustomCollections is now less invasive to ConversionService.
Removed the removal of the general collection-to-object converter as apparently some downstream Spring Data modules rely on it. This theoretically allows conversions of collections into maps but we now simply don't assume that not to work anymore.

Issue #2619.
2022-05-03 22:47:31 +02:00
Oliver Drotbohm
deceb867c5 Support for Eclipse Collections.
Using the newly introduced CustomCollectionsRegistrar SPI to provide support for Eclipse Collections (Imm|M)utable(List|Set|Bag|Map).

Fixes #2618.
2022-05-03 15:46:02 +02:00
Oliver Drotbohm
b3ec06f479 Improve custom collection support.
Custom collection support is now centralized in ….util.CustomCollections. It exposes API to detect whether a type is a map or collection, identifies the map base type etc.

Support for different collection implementations is externalized via the CustomCollectionRegistrar SPI that allows to define implementations via spring.factories. The current support for Vavr collections has been moved into an implementation of that, VavrCollections.

Unit tests for custom collection handling and conversion previously living in QueryExecutionConverterUnitTests have been moved into CustomCollectionsUnitTests.

Fixes #2619.
2022-05-03 15:44:10 +02:00
John Blum
87c5e866ca Improves the CustomConversions API.
* Annotates the API with Spring's @NonNull and @Nullable annotations.
* Re-instates the hasValueConverter(:PersistentProperty) method.
* Removes explamation mark in Exception messages.
* Uses Java 17 language features to simplify code.
* Edits Javadoc.

Closes #2617.
2022-05-02 13:49:24 -07:00
John Blum
5ce9669c7a Additional refinements.
Resolves #2577
Closes #2592
2022-04-29 14:42:39 -07:00
Mark Paluch
cad739c337 Polishing.
Rename generics from C extends PersistentProperty to P extends PersistentProperty.
Refine conversion setup. Make PropertyValueConversions.getValueConverter(…) to return non-null. Return PropertyValueConversions from CustomConversions.

Resolves #2577
Closes #2592
2022-04-29 14:42:28 -07:00
Mark Paluch
cb5201f9d2 Introduce PropertyValueConversionService and specific null-conversion methods.
PropertyValueConverter read and write methods are never called with null values. Instead, PropertyValueConverter now defines readNull and writeNull to encapsulate null conversion. PropertyValueConversionService is a facade that encapsulates these details to simplify converter usage.

Resolves #2577
Closes #2592
2022-04-29 14:40:43 -07:00
John Blum
d384e40e31 Fix mispelling of ClassUtils.getNumberOfOccurrences(..).
* Re-implement getNumberOfOccurrences(..) in terms of a Stream.
* Deprecate the mispelled getNumberOfOccurences(..) method and delegate to the new getNumberOfOccurrences(..) method.
* Edit Javadoc.

Closes #2600.
2022-04-12 11:15:32 -07:00
John Blum
656ef7e874 Fix grammatical errors in Exception messages.
Closes #2599.
2022-04-12 11:12:31 -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
0792b74549 Polishing.
Improve null-safety. Refine exception signature to avoid exception catching.

See #2590
Original pull request: #2591.
2022-04-05 09:16:28 +02:00
Christoph Strobl
b9eb4d1416 Eagerly initialize SimplePropertyValueConversions.
Closes #2590
Original pull request: #2591.
2022-04-05 09:16:28 +02:00
Oliver Drotbohm
3e9451c939 Polishing for full type information on RepositoryMetadata.
Avoid leaking internals from TypeInformation by exposing a ….toTypeDescriptor() method in TypeInformation directly. This causes the ResolvableType handling to become an implementation detail within ClassTypeInformation and avoid client code to manually deal with both ResolvableType and TypeDescriptor creation.

Changed MethodLookups back to use the resolved domain types as the advanced generics resolutions seems not to be needed here and we can avoid

Fixes #2518.
2022-04-04 16:47:54 +02:00
Alex Nistico
58ed9ce211 Use full type information for identifier and domain types exposed byRepositoryMetadata.
See #2518.
2022-04-01 17:45:15 +02:00
Mark Paluch
21e4fd5ffb Allow using Range with Comparator.
Remove Comparable requirement for general Range usage. Comparable is only required for the contains(…) check. Alternatively, accept a Comparator.

Closes #2571
2022-03-28 15:40:29 +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
c85c4ef2ed Polishing.
Tweak Javadoc comments.

See #2585
2022-03-25 13:37:36 +01:00
Mark Paluch
ef5defe405 Retain case-sensitivity and null-handling when changing Sort direction.
We now retain case-sensitivity and null-handling configuration when changing the entire Sort direction.

Closes #2585
2022-03-25 13:35:49 +01: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
89a6c73c3a Polishing.
Fix Javadoc.

See #2566
2022-03-18 15:15:30 +01:00
Mark Paluch
c73c0bfd6d Polishing.
Consistent wording for pageable and sort arguments.

See #2574
2022-03-18 15:09:16 +01:00
Diego Krupitza
1ea8d09b38 Update documentation for repository Pageable and Sort arguments.
Replace outdated `null` acceptance for `Pageable` with `Pageable.unpaged()`
 `QueryByExampleExecutor#findAll(Example<S> example, Pageable pageable)` should does not accept null values since there is `Pageable.unpaged()`. Furthermore, the same applies to `PagingAndSortingRepository#findAll(Pageable pageable)`.

Related ticket: spring-projects/spring-data-jpa/issues/2464
Closes #2574
2022-03-18 15:07:51 +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
Mark Paluch
9a3a38dc22 Accept Object values in QuerydslPredicateBuilder.
We now accept Object-typed values to allow broader reuse of QuerydslPredicateBuilder. The conversion into the actual value considers the origin type and checks assignability before employing the ConversionService.

Closes #2573
2022-03-10 10:22:28 +01:00
Mark Paluch
8b3e4d44f0 Polishing.
Lazily make methods and fields accessible. Introduce invoke method to AnnotationDetectionMethodCallback.

See #2569
2022-03-02 14:54:33 +01:00
Mark Paluch
6bc28c118c Consider annotated methods in AnnotationRevisionMetadata.
We now detect annotated methods.

Closes #2569
2022-03-02 14:54:26 +01:00