Commit Graph

656 Commits

Author SHA1 Message Date
Oliver Gierke
259a1e0958 DATACMNS-891 - Moved to constructor injection for RepositoryFactoryBeanSupport.
RepositoryFactoryBeanSupport now takes the repository interface as a constructor argument instead of as a setter. This makes sure that the container induced type prediction for factory beans actually wires the interface *before* it calls getObjectType() on the instance. This allows us to remove the extra infrastructure we had in place to predict the bean types and autowiring will just work out of the box.

Adapted infrastructure code accordingly, removed obsolete infrastructure code and adapted test cases accordingly.
2016-12-15 14:49:50 +01:00
Oliver Gierke
3a24beecf3 DATACMNS-959 - RepositoryFactorySupport now registers interceptor to detect transactions.
The interceptor discovers whether a transaction was running before the call entered the repository proxy and exposes that fact via ….isSurroundingTransactionActive() for donwstream usage.

Related ticket: DATAJPA-1023.
2016-12-14 15:34:02 +01:00
Oliver Gierke
a76aa4d2a2 DATACMNS-958 - Use ExposeInvocationInterceptor.ADVISOR in RepositoryFactorySupport.
Its usage is recommended over using the instance as advice.
2016-12-14 13:58:47 +01:00
Oliver Gierke
902cb44e86 DATACMNS-940 - Fix query method query result type detection for custom collections.
The nullable wrapper types now expose whether they're a single value type or a multi value type. This is necessary as Javaslang's Option implements Iterable (something we previously checked for to detect a collection query) and the custom collections potentially being usable within other wrapper types (e.g. Future<Seq<User>>).
2016-12-13 15:31:54 +01:00
Oliver Gierke
33b65fbe63 DATACMNS-940 - Support for Javaslang collections as repository return types.
Javaslang's collection and map types can now be used on repository query methods and get adapted similarly to nullable wrapper types (like JDK's Optional). Also made TypeInformation infrastructure aware of the map type so that a value type lookup gets handle correctly.
2016-12-12 20:07:37 +01:00
Oliver Gierke
8f748d6dcf DATACMNS-956 - Ensure consistent use of ClassTypeInformation.from(…). 2016-12-12 17:09:00 +01:00
Oliver Gierke
8af061f389 DATACMNS-941 - Support for downcasts in Querydsl web bindings.
We now support downcasts (e.g. user.as(QSpecialUser.class).…) expressions in Querydsl web binding. We do so by skipping the introduced intermediate step in the path when calculating the dot path.

Refactored the internals of the binding to now work based on a PathInformation implementation for which either a Querydsl Path or a Spring Data PropertyPath can be used. This allows us to reuse the paths of predefined bindings.

A bit of Lombok cleanup in internal implementations.
2016-12-12 16:22:56 +01:00
Oliver Gierke
e1d1a68f49 DATACMNS-953 - Fixed application of GenericPropertyMatchers.exact().
We now really use exact matching for a match setup requesting exact matching. Previously, we erroneously set up the matching with a startsWith().
2016-12-06 10:54:14 +01:00
Oliver Gierke
2377cbac85 DATACMNS-934 - BasicPersistentEntity.addAssociation(…) drops null values now.
Previously a null value was added to the list of associations if it was handed to BasicaPersistentEntity.addAssociation(…). We now drop those null values and log a warning as it usually indicates a MappingContext implementation identifying a property as association but subsequently failing to look it up.
2016-12-05 16:39:05 +01:00
Oliver Gierke
76d1995b37 DATACMNS-952 - Switched from component scanning to SpringFactoriesLoader for internal extension points.
Both the configuration code looking up Spring Data specific Jackson modules as well as the code detecting whether we have multiple Spring Data modules on the classpath used component scanning. That can have quite significant impact on startup times.

This commit replaces the classpath scanning with the use of SpringFactoriesLoader that now requires modules that want to extend the behavior of Spring Data's web configuration or indicate a repository implementation being present by shipping a file called META-INF/spring.factories. Spring Data relies on the following keys:

- org.springframework.data.web.config.SpringDataJacksonModules - list the Spring configuration classes that will expose additional Jackson modules that are supposed to be registered for Spring Data's Jackson web support
- org.springframework.data.repository.core.support.RepositoryFactorySupport - list the Spring Data repository factory implementation class that implements repository support for your module. The general detection and configuration mechanism for user repositories is not affected by this. Currently Spring Data only uses the pure number of different entries for that key to switch into strict configuration mode in case we find more than one entry.
2016-12-05 13:52:55 +01:00
Oliver Gierke
8d67c84809 DATACMNS-951 - Polishing.
Switched to parameterized tests for newly introduced Converters.

Fixed imports and JavaDoc.

Original pull request: #186.
2016-12-05 09:55:46 +01:00
Barak Schuster
3125bbf300 DATACMNS-951 - Added Converter implementations for JSR-310 Duration and Period.
Original pull request: #186.
2016-12-05 09:53:18 +01:00
Oliver Gierke
8062698589 DATACMNS-928 - Reference documentation for event publication support. 2016-12-01 10:17:10 +01:00
Oliver Gierke
c6f9c40472 DATACMNS-928 - Refinements for aggregate root domain event publication.
We now publish events for all methods named "save" on the repository. Fundamentally, that's in place to capture calls to CrudRepository.save(Iterable entities), too.

Some minor refactorings to the internal setup of EventPublishingMethodInterceptor. More JavaDoc.
2016-12-01 10:17:06 +01:00
Oliver Gierke
bdf4738716 DATACMNS-928 - Polishing.
Additional JavaDoc and @since tags. Minor additions to AbstractAggregateRoot.
2016-11-30 18:29:27 +01:00
Oliver Gierke
0fc9770462 DATACMNS-928 - Support for publishing events from aggregate roots.
Introduced @DomainEvents usable on a method of an aggregate root. The method will be invoked when the aggregate is passed to a repository to save and its returned value or values will be exposed via an ApplicationEventListener.

Also, the aggregate can expose a method annotated with @AfterDomainEventPublication which will be invoked once all events have been published.
2016-11-30 18:29:27 +01:00
Oliver Gierke
d3c70d834f DATACMNS-918 - Polishing.
Minor JavaDoc stuff.
2016-11-29 14:09:30 +01:00
Mark Paluch
72e349b006 DATACMNS-918 - Provide interfaces for Pageable and Sort method argument resolvers.
We now provide HandlerMethodArgumentResolver interfaces to resolve Sort and Pageable method arguments with typed return values.
2016-11-29 14:09:23 +01:00
Oliver Gierke
0cc17ffef4 DATACMNS-943 - We prefer direct matches on repository query method overloads.
We now try to look up a target class method based on concrete name and parameter type before falling back on the more expensive type matches. This also eliminates the possibility of invalid method matches as described in the ticket.
2016-11-24 17:21:11 +01:00
Oliver Gierke
50f3565a99 DATACMNS-933 - Updated changelog. 2016-11-23 13:52:31 +01:00
Oliver Gierke
34002d8a9b DATACMNS-937 - Fixed spelling of Javaslang related code.
Using a lower case "s" now.
2016-11-21 12:34:12 +01:00
Mark Paluch
cde3404364 DATACMNS-939 - Do not create queries for static interface methods.
We now no longer attempt query creation for static methods declared on a repository interface. This allows static method usage inside of repository interfaces.

interface PersonRepository extends CrudRepository<Person, String> {

    static String createId() {
        // …
    }

    default Person findPerson() {
        return findOne(createId());
    }
}
2016-11-21 10:32:07 +01:00
Oliver Gierke
3cd76d200d DATACMNS-937 - Document JavaSlang's Option type as query method return type.
Mentioned the support for Scala's Option type, too.
2016-11-19 15:38:44 +01:00
Oliver Gierke
cca9cd8abc DATACMNS-937 - Polishing.
Removed Spring 4.2 guard from QueryExecutionConverter and its unit tests.
2016-11-19 12:49:24 +01:00
Oliver Gierke
1d3af0c128 DATACMNS-937 - Support for JavaSlang's Option type as nullable wrapper.
Repository methods can now return JavaSlang's Option as alternative to JDK 8's Optional or Guavas Optional.
2016-11-19 12:49:21 +01:00
Oliver Gierke
b4518f0583 DATACMNS-920 - Added accessors for Range.lowerInclusive / ….upperInclusive.
Generally improved Range to be a value type by using Lombok's @Value.
2016-11-04 18:37:22 +01:00
Oliver Gierke
0005412383 DATACMNS-924 - Updated changelog. 2016-11-03 18:56:37 +01:00
Oliver Gierke
2e4e6ee61f DATACMNS-929 - Fixed NullPointerException in PageableHandlerMethodArgumentResolver.
PageableHandlerMethodArgumentResolver.isFallbackPageable() now correctly guards against the fallback Pageable being null, a situation that's explicitly deemed valid in setFallbackPageable(…).
2016-11-01 18:04:54 +01:00
Oliver Gierke
0f76ffd491 DATACMNS-925 - Polishing.
Moved an assignment back to its original place to create instance state as early as possible.

Original pull request: #180.
2016-10-16 17:22:54 +01:00
Christoph Dreis
62617bef05 DATACMNS-925 - Improve memory consumption of Parameter and Parameters.
This commit changes some ArrayList initializations to use an initial capacity and avoids the unnecessary fetch of the return type of a method in Parameter.isDynamicProjectionParameter().

Original pull request: #180.
2016-10-16 17:20:43 +01:00
Oliver Gierke
5bb60b6f0b DATACMNS-914 - Updated changelog. 2016-09-29 14:42:00 +02:00
Oliver Gierke
00776d6fe9 DATACMNS-922 - Updated changelog. 2016-09-29 11:42:02 +02:00
Oliver Gierke
7422ba4093 DATACMNS-923 - Removed obsolete code in DefaultRepositoryInformation.
The special case of an Iterable parameter doesn't have to be handled explicitly anymore so that we can simplify the type match check in DefaultRepositoryInformation.

Related ticket: DATACMNS-912.
2016-09-28 17:25:51 +02:00
Oliver Gierke
024f1ae8bd DATACMNS-921 - ResultProcessor now gracefully falls back to approximate collections if necessary.
When handling collection results, we now create an approximate collection in case the creation of the exact same collection fails.
2016-09-28 15:01:19 +02:00
Oliver Gierke
7d901d2005 DATACMNS-916 - Polishing.
Minor formatting changes.

Original pull request: #178.
2016-09-23 14:53:26 +02:00
Mark Paluch
0e29af3a15 DATACMNS-916 - Fix setter lookup in ClassGeneratingPropertyAccessorFactory.
Previously, ClassGeneratingPropertyAccessorFactory uses boxed types for primitive type setters. This threw NoSuchMethodExceptions and caused ExceptionInInitializerError as the generated class could not be initialized. We now use the appropriate argument type to look up setters.

Also, we now only generate accessor usage if the property is configured to use property access in the first place.

Original pull request: #178.
2016-09-23 14:53:26 +02:00
Oliver Gierke
3811ce5873 DATACMNS-917 - Query method execution for Maps now defaults null to an empty Map.
QueryExecutionResultHandler now explicitly handles null values for query methods returning Maps by returning an empty Map. This can be the case if a query is supposed to produce a Map (a single result) but doesn't actually yield any results at all.
2016-09-23 14:46:59 +02:00
Oliver Gierke
8e35c4e41d DATACMNS-913 - Updated changelog. 2016-09-21 08:03:03 +02:00
Oliver Gierke
f09e0d1f71 DATACMNS-873 - Updated changelog. 2016-09-21 08:03:02 +02:00
Oliver Gierke
f44c238784 DATACMNS-912 - Fixed generic method detection for overrides using generic methods.
We now correctly check the bounds of generic methods if we deal with a type variable found as method parameter. Introduced different code paths for type and method level generics so that the latter is explicitly checking all bounds available.
2016-09-20 00:43:27 +02:00
Oliver Gierke
db62390de9 DATACMNS-864 - Tweaks in tests after activation for Spring 5 builds.
After the Spring 5 build profile has been activated properly in Spring Data build [0], the test cases for RepositoryPopulators failed as there was only an explicit detection of Spring 4 to point the test to the right resource file. Removed the guard now as all supported versions can now use the same file.

Adapt to the stricter contract in Spring 5's MethodParameter in unit test for QuerydsPredicateArgumentResolver.

[0] 31df5de907
2016-09-09 23:40:21 +02:00
Oliver Gierke
8ed2bca557 DATACMNS-909 - Mask getDecoratedClass() of Spring 4.3's DecoratingProxy.
The proxies created for projections now defensively mask getDecoratedClass(), a method declared on DecoratingProxy, an interface that JDK proxies on Spring 4.3 will implement.
2016-09-09 21:59:55 +02:00
Oliver Gierke
e294fb5ef4 DATACMNS-908 - Introduced Order.withProperty(…).
The introduced method allows creating new Order instances for a different property ensuring all other aspects (ignore case, null handling) are retained.
2016-09-05 14:46:51 +02:00
Oliver Gierke
acf12423e0 DATACMNS-888 - Added dedicated Sort type to be able to express directions for revisions.
Introduced dedicated RevisionSort property that allows to define the sort order independent of the revision property to be used.

Introduced methods to find out whether a Sort is descending or ascending to avoid having to refer to the enum.
2016-09-01 19:48:23 +02:00
Mark Paluch
8bc022ebd7 DATACMNS-875 - Add support for exists projection in repository query derivation.
We now support exists projections in derived queries by parsing the exists keyword and expose it via PartTree.isExistsProjection().

Original pull request: #171.
2016-09-01 17:36:57 +02:00
Mark Paluch
2b14d1ea54 DATACMNS-899 - Fix recursion in ParameterizedTypeInformation.getMapValueType().
Previously, calls to ParameterizedTypeInformation.getMapValueType() caused an infinite recursion when invoked on a type information that was not a map type. This lead to a StackOverflowError.

We now call the super method doGetMapValueType() instead of calling the entry super method getMapValueType() and return by that null in case the map value type is not resolvable.

Original pull request: #176.
2016-09-01 17:28:10 +02:00
Mark Paluch
ac51b1671d DATACMNS-900 - Added equals(…) and hashCode() methods for ExampleMatcher utility classes.
We now provide equals(…) and hashCode() methods for GenericPropertyMatcher, PropertySpecifier and PropertySpecifiers so that they can be compared and used in sets.

Original pull request: #175.
2016-09-01 17:24:32 +02:00
Jasper Blues
b7f4709b7c DATACMNS-903 - Fix typo in reference documentation.
Original pull request: #170.
2016-08-29 16:31:41 +02:00
Oleksandr Mandryk
1d5273c048 DATACMNS-902 - Fix attribute name in example showing how to define a custom repository base class.
Original pull request: #173.
2016-08-29 16:21:16 +02:00
Kirill Gavrilov
eb2029310f DATACMNS-903 - Fix typo in reference documentation.
Original pull request: #174.
2016-08-29 16:16:31 +02:00