Commit Graph

1352 Commits

Author SHA1 Message Date
Christoph Strobl
a5408a478d Introduce Limit type to limit repository query results.
We now accept Limit as type to express dynamic repository query limits.

Closes #2827
Original pull request: #2836
2023-07-05 10:06:50 +02:00
Yanming Zhou
0d9a91123a Fix outdated Javadoc.
Closes #2860
2023-07-04 15:55:52 +02:00
Mark Paluch
3df0c3b5a6 Retain direction for empty KeysetScrollPosition.
We now retain the direction when an empty KeysetScrollPosition is created.

Closes #2840
2023-07-04 15:53:00 +02:00
Mark Paluch
80b8e12641 Polishing.
Allow nullable OffsetScrollPosition and add support for values wrapped within Optional.

Update tests. Reformat code. Add issue tags to tests.

See #2856
Original pull request: #2861
2023-07-04 15:45:23 +02:00
Yanming Zhou
391607bd14 Introduce argument resolver for OffsetScrollPosition.
Closes #2856
Original pull request: #2861
2023-07-04 15:45:06 +02:00
Oliver Drotbohm
ca9f9bfdc8 Fix query execution mode detection for aggregate types that implement Streamable.
We now short-circuit the QueryMethod.isCollectionQuery() algorithm in case we find the concrete domain type or any subclass of it.

Fixes #2869.
2023-07-01 01:55:59 +02:00
Mark Paluch
6ca3170bde Polishing.
Use ReverseListIterator instead of Stream API to reduce overhead. ListIterator provides means to iterate backwards so we're wrapping the existing iterator.

See #2857.
Original pull request: #2858.
2023-06-16 10:14:28 +02:00
Christoph Strobl
d1568198d8 WindowIterator should emit items in order when scrolling backwards.
Closes #2857
Original pull request: #2858
2023-06-16 10:14:10 +02:00
Mark Paluch
f1b7952ea5 Use merged bean definitions for EntityCallback type lookup.
We now use the merged bean definition to resolve the defined EntityCallback type.

Previously, we used just the bean definition that might have contained no type hints because of ASM-parsed configuration classes.

Closes #2853
2023-06-14 09:25:26 +02:00
Mark Paluch
05d68a0eab Consider KeysetScrollPosition direction in WindowIterator.
We now consider the scroll direction in the iterator to properly continue Keyset backward scrolling.

Closes #2851
2023-06-13 11:52:34 +02:00
Mark Paluch
bfcb2ffeae Unwrap nested collections in default Querydsl binding.
When binding values to collection-like paths, we now unwrap potentially double-wrapped collections as QuerydslPredicateBuilder attempts to convert the binding value to the type of the path.

Our default is a contains binding for single elements.

Closes #2834
2023-06-02 10:29:57 +02:00
Mark Paluch
9b9d01c1a0 Adopt to changed AwaitKt utility.
Closes #2832
2023-05-23 11:59:20 +02:00
Mark Paluch
c6879a8bf6 Refine allocation of DefaultMethodInvokingMethodInterceptor.
We now reduce allocations of DefaultMethodInvokingMethodInterceptor by reusing DefaultMethodInvokingMethodInterceptor within a ProxyProjectionFactory. We also reduced allocations during default method discovery and reuse the default methods information within the projection information cache.

Closes #2831
2023-05-17 10:33:07 +02:00
Mark Paluch
46ff9d25a6 Allow reversing Sort.
We now allow reversing the sort order of Sort instances to flip ASC and DESC sort orders.

Closes #2805
2023-05-11 16:13:19 +02:00
Mark Paluch
1ba2932275 Polishing.
Reorder methods.

See #2823
2023-05-11 16:13:18 +02:00
Jens Schauder
fd0964ab72 Make all args Sort.Order constructor public.
The other constructors are already public, and this one is actually needed by subclasses.

Closes #2823
2023-05-11 16:12:59 +02:00
Mark Paluch
69dbb75896 Polishing.
Remove superfluous declarations, fix toString description.

See #2824
2023-05-11 11:10:44 +02:00
Stefano Cordio
63fecdd06e Fix Sort JavaDoc.
Original pull request #2825
2023-05-03 10:38:29 +02:00
Oliver Drotbohm
979e0f401b Fix too restrictive entity callback matching.
We now properly support generic entity callbacks defined via lambda declarations.

Fixes #2822.
2023-05-02 20:54:49 +02:00
Oliver Drotbohm
cac1c211ef Polishing Window scrolling API.
Moved general-purpose factory methods to the common ScrollPosition interface. Introduced a couple of domain specific methods to conveniently work with both Keyset- (to e.g. change direction) and OffsetScrollPosition (to e.g. advance the offset). Consolidated unit tests accordingly.

Moved WindowIterator to ….data.support package. Fixed case of Direction enum values.

Fixes #2824.
2023-04-27 18:02:30 +02:00
Oliver Drotbohm
c3b29a5644 Polish Javadoc of PersistentEntity regarding iteration order of PersistentProperty instances.
Fixes #2814.
2023-04-04 13:23:44 +02:00
Oliver Drotbohm
03a6a84bf9 Polishing in mapping package.
Nullable annotations and Objects.equals(…) and Objects.hash(…)/Objects.hashCode(…). Records for internal cache key.

Related issue: #2813.
2023-04-04 11:32:52 +02:00
Oliver Drotbohm
55e14952c8 Remove deprecations in PersistentPropertyAccessor.
Related issue: #2813.
2023-04-04 11:32:52 +02:00
Oliver Drotbohm
35a2f45736 Tighten nullability contract of PersistentPropertyPath.
We should change the definition of `PersistentPropertyPath` to — in its public API — not allow empty instances anymore. Those violate the concept and bleed into the concept's API by having to make all methods nullable (returning null in exactly that "empty" case). An empty property path doesn't make any actual sense as you cannot reasonably answer the methods declared on the interface except by returning null, which then causes client code having to verify the returned values all the time.

This is now changed into only making `PersistentPropertyPath.getParentPath()` nullable and letting it return null for single segment paths. Adapted client code accordingly. `….getRequiredLeadProperty()` is now deprecated in favour of `….getLeafProperty()` not returning null anymore.

Fixes #2813.
2023-04-04 11:32:43 +02:00
Oliver Drotbohm
83162b25c7 Improve lambda-based EntityCallback detection.
In case an EntityCallback is declared as lambda expression, the JVM does not expose any generics information about the target entity type the callback shall be applied to. This commit changes the callback lookup and processing so that in case the generics information is not detectable on the type, we fall back to the BeanDefinition's resolvable type (fed by the factory method's return type which carries the necessary reflection information). That generics information is then kept in the newly introduce EntityCallbackAdapter and the code inspecting the actual entity type for matches then uses the resolvable type held in that. Also, the actual callback invocation is done on the adapter's delegate.

Removed the ability of the discoverer to register EntityCallbacks by bean name as that was not used in the public API at all and it avoids duplicating the bean definition type detection. A couple of minor additional cleanups (records for cache key, methods static where possible and with lower visibility etc.)

Fixes #2812.
2023-04-04 09:23:29 +02:00
Michael J. Simons
a257a0399a Gracefully skip non-assignable reactive lambda callbacks on Java 18+.
Closes #2808, #2809.
2023-04-04 09:05:02 +02:00
Mark Paluch
2564f6a049 Polishing.
Refactor WindowIterator to return individual objects during scrolling.

Original Pull Request: #2787
2023-03-16 13:11:50 +01:00
Christoph Strobl
0c0c1afc8e Add WindowIterator and rename Scroll to Window.
The intend of WindowIterator is to support users who need to iterate multiple windows. It keeps track of the position and loads the next window if needed so that the user does not have to interact with the position at all.

Also remove the Window methods to get the first/last position and enforce the index based variant.

Update the documentation to make use of the newly introduced API.

See: #2151
Original Pull Request: #2787
2023-03-16 13:10:40 +01:00
Mark Paluch
035965a3a2 Introduce Scroll API.
See: #2151
Original Pull Request: #2787
2023-03-16 13:09:39 +01:00
Oliver Drotbohm
116730c168 Polishing.
Imports, Javadoc, ticket references in test cases.

Removed the need for MethodParameterAware… flavors of the ResourceAssemblers by keeping the MethodParameter reference in the original assemblers in the first place. Extracted common Pageable MethodParameter lookup code into PageableMethodParameterUtils.

Related ticket: #1307.
2023-02-28 17:00:37 +01:00
Michael Schout
70f21bda9f Add SlicedResourcesAssembler for web integration.
Added SlicedResourcesAssembler to esaily convert Slice instances into SlicedResource instances and automatically build the required previous/next link based on PageableHandlerMethodArgumentResolver present in the MVC configuration. The assembler can either be injected into a Spring MVC controller or a controller method. The latter will then assume the controller methods URI to be used as pagination link base.

Added necessary SlicedResourcesAssemblerArgumentResolver and MethodParameterAwareSlicedResourcesAssembler classes and wire up HateoasAwareSpringDataWebConfiguration configuration beans to that SlicedResourcesAssembler's can be auto-injected into controllers.

Closes #1307
2023-02-28 10:06:10 +01:00
Mark Paluch
83655663ea Refine QuerydslRepositoryInvokerAdapter nullability assertions.
QuerydslRepositoryInvokerAdapter now rejects null predicates to enforce nullability constraints.

Closes #1501
2023-02-24 11:04:11 +01:00
Mark Paluch
f82a48454e Polishing.
Use consistently domain type instead of introducing a new terminology to repository infrastructure.

Rename Kotlin variant of ParameterUnitTests to KParameterUnitTests to avoid duplicate classes.

See #2770
Original pull request: #2771
2023-02-14 14:29:12 +01:00
Oliver Drotbohm
16e7e7c79b Query method parameters are now aware of aggregate reference type.
To support the binding of Class parameters to queries for declared query methods, we have to be able to differentiate them from Class parameters that are supposed to represent projections. We can do that by relating the declared Class' element type to the aggregate root type as a Class typed to that or any subtype of it will never trigger a projection by definition.

So far the Parameter(s) abstraction was solely created from a query method's Method. We now changed that for QueryMethod to forward the aggregate type detected on the RepositoryMetadata and consider it during the detection of dynamic projection parameters.

As a mitigating measure, we now also support @Param on Class-typed parameters to explicitly mark them for query binding. This is primarily to be able to add this support to the 2.7

The changes are built in a way that modules extending that mechanism will continue to work as is but see deprecation warnings on methods and constructors involved. Adapting extending code to the new APIs will automatically enable the support for bindable Class parameters on query methods.

Fixes #2770.
Original pull request: #2771
2023-02-14 14:28:05 +01:00
ByungjunYou
7cf4cf9baa Fix a typo in javadoc.
Closes #2739
2023-01-23 14:13:37 +01:00
Mark Paluch
b3dcbbe1a7 Polishing.
Reorder statements for higher cohesion.

See #2760
Original pull request: #2762
2023-01-11 11:15:39 +01:00
Christoph Strobl
0bd2714595 Use unique bean name for configuration post processors.
Closes #2760
Original pull request: #2762
2023-01-11 11:15:39 +01:00
Mark Paluch
4c2b8ac4c8 Polishing.
Introduce common exclusion rules for constructors.

See: #2744
Original pull request: #2746
2023-01-11 11:11:14 +01:00
Christoph Strobl
1d7c1ff6e0 Exclude synthetic constructors from AOT inspection.
Java8 bytecode may contain synthetic constructors that refer to anonymous classes which should not be inspected.

Eg. the following construct results in bytecode as listed further down below.

public enum Outer {

    INSTANCE {
        @Override
        public Inner getInnerType() {
            return Inner.STANDALONE;
        }
    },

    public abstract Inner getInnerType();
}

synthetic Outer(java.lang.String arg0, int arg1, Inner$1 arg2)

See: #2744
Original pull request: #2746
2023-01-11 11:08:13 +01:00
Christoph Strobl
a2b3615572 Exclude local and anonymous classes from AOT type inspection.
Also update the type filter that would not mach types directly present in the given package.
Modify type contribution method to allow store specific override.

Closes: #2744
Original pull request: #2746
2023-01-11 11:08:13 +01:00
Oliver Drotbohm
6fd8ae4917 Improve Lazy.toString().
Added dedicated Lazy.toString() rendering the resolved value's ….toString() method but resorts to a constant [Unresolved] if it's not already resolved. An additional ….toString(Supplier<String>) allows to customize the fallback message if needed.

Fixes #2751.
2023-01-05 11:45:00 +01:00
Mark Paluch
14919995ad Extend license header copyright years to 2023.
See #2756
2023-01-02 09:53:28 +01:00
John Blum
bdfb1f8a7f Fix formatting in PropertyReferenceException message.
A message like, "No property 'creat' found for type 'User' Did you mean ''created''" is now properly formatted as:
"No property 'creat' found for type 'User'; Did you mean 'created'".

Closes #2750.
2022-12-12 13:02:23 -08:00
Mark Paluch
f8d6c9f026 Polishing.
Avoid caching. Expand exception handling to all reflective exceptions. Fix since tags.

See: #2721
Original pull request: #2743.
2022-12-12 10:37:56 +01:00
Christoph Strobl
016e8c2779 Register reflection hints for Querydsl Q types.
This commit introduced support for registering GraalVM native reflection type hints for Querydsl Q types that target domain types used in the repository interface declaration.

At this point we only do a simple lookup for Q types based in the very same package that implement EntityPath.
More advanced configuration (eg. base package and type prefix), potentially available via EntityPathResolver are not taken into account as this would require eager bean resolution from the application context, which is likely to trigger additional infrastructure. In this case the user is required to register Q types manually.

Closes: #2721
Original pull request: #2743.
2022-12-12 10:37:56 +01:00
Jens Schauder
d56bbbdefb Make dependency tests based on ArchUnit.
The DependencyTests are reimplemented using ArchUnit and enabled.

See #2708
Original pull request #2706
2022-11-02 11:08:37 +01:00
Mark Paluch
6190baa3db Move ReactiveWrappers into o.s.d.util package.
ReactiveWrappers is not tied to repositories so it does not need to reside in the repository.util package. This utility is now located in the data.util package for a better module design and to prevent package cycles.

See #2708
2022-11-02 10:52:11 +01:00
Mark Paluch
5b784d006f Polishing.
Remove duplicate license headers. Avoid fully-qualified type usage where possible.

See #2708
2022-11-02 10:51:42 +01:00
Christoph Strobl
8d424855da Resolve package cycle between repository.config and repository.aot.
Closes #2708
2022-11-02 10:51:26 +01:00
Mark Paluch
92a6ec800c Polishing.
Use for-loop instead of stream to reduce overhead.

See #2722
2022-10-27 09:36:31 +02:00