Commit Graph

513 Commits

Author SHA1 Message Date
Oliver Gierke
db2a09192b DATACMNS-785 - Added RevisionRepository.findRevision(ID, N). 2015-11-16 17:09:32 +01:00
Oliver Gierke
2564e0e8b1 DATACMNS-784 - Updated changelog. 2015-11-16 08:25:50 +01:00
Oliver Gierke
d2737983c3 DATACMNS-783 - DefaultTypeMapper now specializes raw generic types.
If the type lookup from the store source returns a raw generic type (e.g. resolving the value of a generic property against a value of that generic type - i.e. not a more concrete type binding the generic information) in the context of a generic property, we previously did not apply the generics information of the contextual instance to that very raw type.

We now expose a TypeInformation.specialize(ClassTypeInformation) which applies the current generics context to the given raw type and basically creates a synthetic parameterized TypeInformation instance.

DefaultTypeMapper applies this specialization by default now with ClassTypeInformation simply returning the given type as is so that we don't create any resolution overhead in case no generics are involved in the first place.
2015-11-13 17:16:47 +01:00
Oliver Gierke
0d6476c642 DATACMNS-782 - ProxyProjectionFactory now converts primitive attribute values.
The ProjectingMethodInterceptor now uses a default ConversionService instance to try to convert a potentially not matching result of the target invocation into the type the projection requires before the attempt to create nested projection.
2015-11-12 11:17:43 +01:00
Oliver Gierke
d3a194c408 DATACMNS-779 - Fixed JavaDoc in QuerydslPredicateBuilder.
Added JavaDoc to the constructor of QuerydslPredicateBuilder.
2015-10-22 11:45:17 +02:00
Oliver Gierke
896cc76fc7 DATACMNS-777 - Updated changelog. 2015-10-14 14:08:23 +02:00
Oliver Gierke
1185e71214 DATACMNS-768 - Added support for Optional as query method parameter type.
Query method parameter values of JDK 8 or Guava Optional type are now transparently unwrapped on parameter value access. ParametersParameterAccessor now unwraps them on instance creation.
2015-10-07 19:28:19 +02:00
Ricardo Espirito Santo
91eaf1bc50 DATACMNS-771 - Fixed typo in BasicPersistentEntity.
Original pull request: #145.
2015-10-05 18:32:07 +02:00
Oliver Gierke
828c19a4e5 DATACMNS-773 - Added support for persisting ZoneId instances as Strings.
We now ship converters for JSR-310 and ThreeTenBP's ZoneId conversion to String and back.
2015-10-05 18:03:42 +02:00
Oliver Gierke
be47572e56 DATACMNS-769 - Fixed assignability check for from QueryMethod.
The assignability check of method return types now explicitly detects wrapper types supported in QueryExceutionConverters and automatically unwraps those before the actual check.
2015-10-05 12:04:26 +02:00
Oliver Gierke
01f2c30b1d DATACMNS-753 - Fixed default handling of empty sort parameter.
We now correctly inspect the sort parameter values and also fall back to the default if a single, empty parameter value is given.

Related ticket: DATACMNS-408.
Related pull request: #138.
2015-09-09 17:56:27 +02:00
Ruben Dijkstra
9d9f230ed4 DATACMNS-753 - Added test case to see parsing of Sort is not considering defaults for empty parameter.
Related ticket: DATACMNS-408.
Original pull request: #138.
2015-09-09 17:55:43 +02:00
Oliver Gierke
360e473c3a DATACMNS-763 - Fixed constructor in example of custom repository base class.
Added hint to which constructor of the superclass to override. Added test cas e to make sure the expected types are advertised in the case of an error.
2015-09-07 09:15:13 +02:00
Oliver Gierke
8992cc80a1 DATACMNS-762 - Polished section on dependencies in reference documentation.
Linked back to the release train names from the section on dependency management with Boot for clarity. Added additional line break to avoid the first line in the repositories.adoc being interpreted as text.
2015-09-03 18:13:50 +02:00
Oliver Gierke
167b52f7b4 DATACMNS-761 - Fixed page size detection for a PageableHandlerMethodArgumentResolver configured to one-indexed parameters. 2015-09-02 16:13:36 +02:00
Oliver Gierke
37830dae6e DATACMNS-759 - Prepare 1.11.0.RELEASE (Gosling GA). 2015-09-01 09:44:21 +02:00
Oliver Gierke
05d4b0d3b6 DATACMNS-759 - Updated changelog. 2015-09-01 09:44:09 +02:00
Oliver Gierke
8c90594e9e DATACMNS-760 - Removed cyclic dependency in Querydsl packages.
Moved @QuerydslPredicate into the non-web-related Querydsl package to avoid a cyclic dependency.
2015-09-01 09:23:04 +02:00
Christoph Strobl
ed64dd186e DATACMNS-751 - Added newly introduced features to the reference documentation.
Added sections to the reference documentation to elaborate on the newly introduced web integration for Querydsl.

Added documentation for Future<T> return types.

Corrected the closing tag for dependency for Spring Data Commons section on dependencies. Fix broken links to Spring Framework reference documentation. Update build requirements in readme.

Original Pull Request: #137
2015-08-19 10:19:28 +02:00
Oliver Gierke
cc2696fcc4 DATACMNS-755 - Fixed QSort property translation for plain paths.
If standard Querydsl StringPaths are used without any reference to a query class tree, we previously dropped the first segment of the path expression.

Moved to a completely different algorithm to determine the path by just using the Path's toString() representation and the root removed if necessary.
2015-08-18 13:53:02 +02:00
Martin Grigorov
d61b687cd6 DATACMNS-754 - Fixed code sample in repositories reference documentation.
PersonRepository example now shows Person persisted instead of User instances.

Original pull request: #140.
2015-08-17 18:14:27 +02:00
Oliver Gierke
cc1aa713f9 DATACMNS-750 - Fixed part creation in query methods that have keywords in property paths.
If a keyword was contained in a complex property path (like In in SomeInfo), the property path was invalidly cut of in the middle. We now simply use the length of the keyword to extract the actual property from the candidate. This should be faster anyway as it doesn't require another lookup of the pattern in the source candidate.

Related pull request: #136.
2015-08-13 12:37:30 +02:00
Oliver Gierke
6775d11c65 DATACMNS-749 - RepositoryFactorySupport now registers global ExposeInvocationInterceptor.
This frees RepositoryProxyPostProcessors from having to register the interceptor manually and thus prevents it from being registered multiple times.
2015-08-08 10:58:06 +02:00
Oliver Gierke
7b791d2825 DATACMNS-748 - Fixed Spring 4.2 detection in QueryExecutionConverters.
Replaced the unreliable usage of SpringVersion.getVersion() with a dedicated lookup for a type only present in Spring 4.2.
2015-08-08 10:51:09 +02:00
Oliver Gierke
1befa529e9 DATACMNS-746 - Improved JavaDoc of PersistentPropertyAccessor.
The JavaDoc of PersistentPropertyAccessor now explicitly hints to PersistentEntity.getPropertyAccessor(…) to make obvious how instances of it can be obtained.
2015-08-07 16:16:21 +02:00
Oliver Gierke
e3d62ea213 DATACMNS-742 - Prepare 1.11.0.RC1 (Gosling RC1). 2015-08-04 11:56:20 +02:00
Oliver Gierke
ec2e33f408 DATACMNS-742 - Updated changelog. 2015-08-04 11:56:20 +02:00
Oliver Gierke
9afb5777e9 DATACMNS-744 - Removed strong dependency to Querydsl in web support.
Moved all Querydsl related bean definitions and customizations to a dedicated configuration class that only gets included if Querydsl is on the classpath.

Extracted a QuerydslActivator for use in Spring Data REST, which uses HateoasAwareSpringDataWebConfiguration via inheritance, not via @EnableSpringDataWebSupport.

Previously, we exposed a QuerydslBindingsFactory as bean method return type which breaks Spring bootstrap even if it's lazy due to its references to Querydsl types.

Related tickets: DATACMNS-669.
2015-08-04 09:05:58 +02:00
Oliver Gierke
8d2933f109 DATACMNS-669 - Introduced QuerydslBindingsFactory.
QuerydslBindingsFactory creates a completely build up and customized QuerydslBindings instance for a given QuerydslBinderCustomizer type and domain type.

This basically involves creating or obtaining an instance of the customizer with the following algorithm:

1. If an explicit customizer type is given and no BeanFactory is configured, we'll simply instantiate the configured type. This allows simple customizer implementations with a no-arg constructor.
2. If a BeanFactory is configured and a customizer type configured, we're trying to locate a bean of that type in the BeanFactory, falling back to creating an instance of the customizer through the BeanFactory if no existing bean definition can be found. This allows unique customizer bean definitions or complex prototype scoped customizer beans created on the fly.
3. If no customizer type is configured, we check whether the the repository of the domain type implements QuerydslBinderCustomizer and use it if so.

The extraction of that functionality allows that algorithm being used by Spring Data REST, although only step 3 is currently used there as no explicit customizer can currently be configured with Spring Data REST.
2015-08-03 15:34:47 +02:00
Oliver Gierke
9dc581df43 DATACMNS-738 - Removed deprecations in BeanWrapper.
Removed deprecated static factory method and made the class package protected.
2015-08-03 15:34:47 +02:00
Oliver Gierke
1a0e1aa5dd DATACMNS-740 - Updated changelog. 2015-07-28 16:40:53 +02:00
Oliver Gierke
85d96c71f2 DATACMNS-736 - Polishing.
Tweaked unit test to check for the correct wording. Polished DistanceFormatterUnitTests to actually run in a Maven build.

Original pull request: #134.
2015-07-21 16:52:48 +02:00
David Syer
a597549c4e DATACMNS-736 - Fixed validation error message in PointFormatter.
PointFormatter error message now states it's expecting comma separated values. Previously it erroneously reported expecting a semicolon.

Original pull request: #134.
2015-07-21 16:52:44 +02:00
Oliver Gierke
e3668c621d DATACMNS-734 - Improved Querydsl predicate binding using formatters.
We now default to a FormattingConversionService to make sure comma-separated values are transformed into arrays correctly. Also, we now build up dedicated TypeDescriptor instances for the property or field about to be bound to potentially pick up formatting annotations on those.
2015-07-21 15:47:09 +02:00
Christoph Strobl
11056be292 DATACMNS-734 - Allow comma separated list of values to be bound to an array.
We now convert comma separated values for an array property by splitting values and converting each of them. This allows to convert address.location=40.740337,-73.995146 to 

class Address {
  Double[] location;
}
2015-07-21 15:47:09 +02:00
Oliver Gierke
ac080bacf7 DATACMNS-733 - Made all references to DefaultParameterNameDiscoverer non-static.
To prevent classes from being garbage collected due to Class<?> references within DefaultParameterNameDiscoverer we no keep all ParameterNameDiscoverer instances in a non-static field.
2015-07-20 08:28:26 +02:00
Oliver Gierke
c5e5244162 DATACMNS-669 - Moved some types for better code structure.
Introduced dedicated querydsl.bindings package to contain all non-web projects to make sure domain types and repositories don't have to depend on types in a web package.

Updated Sonargraph architecture description accordingly.

Original pull request: #132.
2015-07-20 08:12:28 +02:00
Oliver Gierke
0330cdc3d3 DATACMNS-669 - Final polishing.
Mostly Javadoc. Removed all API that took String paths so far.

Changed return type of bean definition for QuerydslPredicateArgumentResolver to HandlerMethodArgumentResolver so that Querydsl stays optional during class loading.

Original pull request: #132.
2015-07-20 08:12:20 +02:00
Christoph Strobl
64c8549db4 DATACMNS-669 - Register QuerydslPredicateArgumentResolver as bean.
If no QuerydslBinderCustomizer is configured on @QuerydslPredicate specifically, we now also consider the domain types repository as candidate for binding customization.

The lookup algorithm for explicitly configured customizers has been refined to try to find a bean in the BeanFactory first, resorting to on-the-fly creation eventually.

QuerydslPredicateArgumentResolver is now registered as a lazily initialized bean and its usage is guarded by checking presence of Querydsl itself.

The according test needs to do some reflection in order to stay out of trouble when types are loaded by different class loaders required to hide certain types.

Original pull request: #132.
2015-07-20 08:12:14 +02:00
Oliver Gierke
cccfa5e5c5 DATACMNS-669 - Polishing.
Javadoc on MultiValueBinding. Hide QuerydslBindings.bind(…), ….include(…) and ….exclude(…) methods that take String arguments to reduce the probability of no query class being present.

Refined the value handling for empty request values which are represented as String[] containing an empty String. We now massage those into an empty Collection for MultiValueBindings and a null value for SingleValueInvocations.

We currently skip property values that match this pattern entirely but are prepared to allow a configuration flip switch to handle those scenarios in the future. We currently stick to skipping those values to prevent the bindings from having to deal with null values.

We now also allow the bindings to return null to indicate they don't want to get applied in the resulting predicate at all.

Switched to interface based customization to make it easier to use customizations with Spring Data REST. Added Querydsl-specific adapter of RepositoryInvoker to allow Spring Data REST to hook in the execution of the predicate obtained from request parameters.

Original pull request: #132.
2015-07-20 08:12:11 +02:00
Christoph Strobl
dc49101850 DATACMNS-669 - Ignore non-reachable paths for Querydsl parameter binding.
We now ignore invalid PropertyPaths on property binding to Querydsl Predicates. Those may occur since the request also holds non-property-related arguments, such as pagination parameters.

Fixed two potential NullPointerExceptions along the way since we no longer depend on the presence of @QuerydslPredicate.

Original pull request: #132.
2015-07-20 08:11:47 +02:00
Oliver Gierke
5db3def79b DATACMNS-669 - Polishing.
QuerydslBindings now uses a builder style pattern to define custom bindings. This allows to define the same binding for multiple properties of the same type in one configuration call.

Introduced MultiValueBinding to be able to register a binding for multiple source values (i.e. if multiple values are provided for the same parameter). The previously named QuerydslBinding is now a SingleValueBinding which gets adapted to by extracting the first element of the values provided considered as collection.

Slightly refined the generics signature in QuerydslBinding for better type derivation in Lambdas. Removed the need for QuerydslBindingContext by moving a few properties around. The ConversionService instance is now piped into the QuerydslPredicateBuilder directly.

Added a bit of sample data to the Users test domain type to be able to execute the generated Predicates in tests to validate their correctness.

Original pull request: #132.
2015-07-20 08:11:28 +02:00
Christoph Strobl
e645501174 DATACMNS-669 - Added support to bind Querydsl Predicates to Spring MVC controllers.
Adding @QuerydslPredicate to a parameter within SpringMVC Controller when having registered the QueryDslPredicateArgumentResolver allows to generate a Querydsl Predicate based on the request parameters.

Parameters will be converted into their corresponding property types before using the as predicate value. Given more than one attribute will connect those using 'and'. Collections of values will force usage of 'in' while single values on collection like properties result in 'contains'.

The base type for building the Querydsl Path is extracted from the methods return type. In case of non domain type return values it can optionally be specified via @QueydslPredicate(root = …). Specific Predicate conversions can be registered via '@QuerydslSpecification'.

This allows to sneak in specific property path handlings more easily.

new QueryDslPredicateSpecification() {
  {
    define(new StringPath("address.city"), (path, value) -> path.like(value.toString()));
  }
};

Renamed resolver, accessor etc. to express operation of binding properties to a resolved path and introduced explicit binding context which allows reuse of predicate builder within the ArgumentResolver.

Added registration of QuerydslPredicateArgumentResolver directly in SpringDataWebConfiguration reusing the provided ConversionService.

Added Javadoc and changed visibility of non public API and types.

Original pull request: #132.
2015-07-20 08:11:04 +02:00
Oliver Gierke
30b4cf53fc DATACMNS-715 - Introduced support for JTA 2.1 @Transactional.
Refreshed the copy of AnnotationTransactionAttributeSource to pull in the JTA 2.1 support introduced in the Spring Framework class. Opened up a ticket [0] to improve Spring Framework to eventually be able to ditch the copies to prevent such scenarios in the future (the missing feature introduced that is).
2015-07-17 09:43:24 +02:00
Oliver Gierke
174e9a6e93 DATACMNS-731 - Parameter now exposes whether it's named explicitly.
Parameter now has a isExplicitlyNamed() to indicate whether the user explicitly assigned a name to it in contrast to an implicitly discovered parameter name.
2015-07-15 16:18:37 +02:00
Oliver Gierke
cd6b2c09c6 DATACMNS-542 - Be more lenient about simplified way to customize repository base classes.
We now leniently return null for the repository base class name from the AnnotationRepositoryConfigurationSource to make sure Spring Data modules compile against Spring Data Commons 1.10 continue to work on 1.11 without having the annotation attribute added.
2015-07-13 17:39:49 +02:00
Oliver Gierke
709bb5c4b1 DATACMNS-727 - Improved error handling in MappingContext.getPersistentPropertyPath(…).
A failure to resolve a property path into a PersistentPropertyPath now causes an InvalidPropertyPath exception being thrown. It captures the context of the failure like the resolved path, the offending segment. Added getPersistentPropertyPath(InvalidPropertyPath) that resolves the resolvable part for further use downstream.

Added null-checking assertions to AbstractMappingContext.getPersistentPropertyPath(…) variants. Improved DefaultPersistentPropertyPath to be able to append properties while building and to allow representing an empty path.
2015-07-09 14:10:26 +02:00
Oliver Gierke
d859540f92 DATACMNS-703 - PropertyReferenceException now exposes potential matches.
We now use Spring's PropertyMatches to build up the exception message and include a list of potentially meant properties.

Removed unused config file for tests along the way.

Original pull request: #125.
2015-07-06 12:44:13 +02:00
Oliver Gierke
2cb2830d59 DATACMNS-723 - Updated changelog. 2015-07-01 09:52:17 +02:00
Oliver Gierke
eb4f7e245d DATACMNS-724 - Updated changelog. 2015-07-01 07:30:48 +02:00