Commit Graph

357 Commits

Author SHA1 Message Date
Phillip Webb
8156c2a151 DATACMNS-710 - Replace ObjectInstantiatorClassGenerator
Deprecate ObjectInstantiatorClassGenerator and provide a replacement
ClassGeneratingEntityInstantiator which doesn't retain a reference to
the context class loader.

Original pull request: #128.
2015-06-15 22:16:43 +02:00
Oliver Gierke
b60f5d84ec DATACMNS-648 - Parameters now holds a non-static ParameterNameDiscoverer.
Turned the previously static ParameterNameDiscoverer into an instance variable to make sure the instance can be GCed correctly.
2015-06-15 18:01:42 +02:00
Oliver Gierke
de4f1ffb7b DATACMNS-713 - PageImpl now adapts total if necessary.
On a last page the total handed into a PageImpl constructor might not necessarily fit the content as there's the change of an insertion or deletion between the calculated count and the retrieval of the content. We now leniently mitigate those differences if the page created is the last page of the result.

Related tickets: DATAJPA-728, DATACMNS-615.
2015-06-15 14:24:03 +02:00
Oliver Gierke
7107a599bb DATACMNS-710 - ObjectInstantiatorClassGenerator now uses default class loader.
We're now using ClassUtils.getDefaultClassloader() to make sure we adhere to any class loading tricks the framework might impose for domain type instantiation.
2015-06-09 22:01:25 +02:00
阮杰锋
a57bac07e2 DATACMNS-707 - Fixed typo in JavaDoc of CrudRepository
Changed from ( to { in JavaDoc of file CrudRepository.

Original pull request: #127.
2015-06-09 11:33:41 +02:00
Oliver Gierke
501f0c8493 DATACMNS-700 - ReflectionRepositoryInvoker now captures context for failed parameter conversions.
Introduced QueryMethodParameterConversionException to capture the context of a failed ConversionException to allow better error reporting.

Cleaned up test cases to not use deprecated API anymore.
2015-05-22 10:29:19 +02:00
Oliver Gierke
1fb7466065 DATACMNS-701 - First and last links are now always rendered for navigable PagedResources.
We now always render both first and last links in case the page returned is navigable, which essentially means: whenever the result spans across more than one page. I.e. whenever either a next or prev link will be rendered, both first and last links are rendered, too.

Clients can still reason about the fact whether they're on the first or last page by the non-presence of prev (indicates you're on the first page) or next (indicates you're on the last page).
2015-05-20 13:33:53 +02:00
Oliver Gierke
62170ab767 DATACMNS-701 - PagedResourcesAssembler now adds first and last links.
We now add first and last links to the PagedResources created in line with the appearance of the prev and next links. The PagedResourcesAssembler can be configured to enforce the rendering using setForceFirstAndLastRels(…).
2015-05-20 13:30:41 +02:00
Oliver Gierke
c5aaebd0e4 DATACMNS-699 - PagedResourcesAssembler now allows to create empty Page with type information. 2015-05-18 16:19:14 +02:00
Oliver Gierke
65104a4a3a DATACMNS-697 - TypeDiscoverer now considers field-local generics information.
In case we create a ParameterizedTypeInformation for a property we now also analyze the field-local generics information and add the discovered type mappings to the type variable map.
2015-05-16 18:55:47 +02:00
Oliver Gierke
6ebb05e606 DATACMNS-515 - Links for PagedResources should be canonical.
PagedResourcesAssembler now creates the self, prev and next links for a PagedResource to be canonical and not contain any template parameters. This is to make sure a client can not actually tweak the links and follow a link that's not strictly conforming to semantics of the rel.
2015-05-14 14:06:35 +02:00
Oliver Gierke
5b60d487e1 DATACMNS-695 - Fixed potential NullPointerException in AbstractMappingContext.getPersistentPropertyPath(…).
When traversing nested property paths, AbstractMappingContext.getPersistentPropertyPath(…) previously used the raw actual property type. If the property path contains a reference to a generically typed property, this causes the deeper paths not being resolved correctly.

We now explicitly use the TypeInformation of the property to retain generics information while traversing the path.
2015-05-13 18:33:58 +02:00
Oliver Gierke
9230b5f30f DATACMNS-692 - Fixed web parameter range handling for Pageables.
In case the PageableHandlerMethodArgumentResolver was configured to use one-indexed parameters, it wasn't defaulting the lower bounds for the page number. This caused indexes out of the allowed bound submitted causing an invalid index handed tor PageRequest. We now apply better range shifting before the bounds are applied.
2015-05-13 18:00:19 +02:00
Tomasz Wysocki
024dd50d92 DATACMNS-693 - AbstractMappingContext now uses Spring's BeanUtils to lookup PropertyDescriptors.
Instead of manually using Introspector.getBeanInfo(…) we now use Spring's BeanUtils.getPropertyDescriptors(…) to benefit from some caching of descriptor instances as well as advanced support for fluent setters, default methods etc.

Original pull request: #122.
2015-05-13 13:22:57 +02:00
Oliver Gierke
2d62c149bb DATACMNS-542 - Simplified way to customize repository base class.
RepositoryFactorySupport now exposes a setRepositoryBaseClass(…) to take a custom type that instances will be created reflectively for. This removes the need for a boilerplate repository factory and FactoryBean implementation to hook custom repository base class implementations into the infrastructure.

RepositoryFactorySupport now exposes a getTargetRepositoryViaReflection(…) method to allow sub-classes to create repository instances and consider customized repository base classes nonetheless. getTargetRepository(…) needs a tiny signature change which unfortunately requires imple

Fixed schema registration for version 1.8 schema. Added new XSD containing a base-class attribute on the <repositories /> element to customize the repository base class via XML.

Removed outdated section of how to create a custom base repository class from the reference documentation and replaced it with new simplified instructions.

Deprecated usage of factory-class attribute in configuration. Point users to newly introduced way of configuring a base class directly to avoid the need for a boilerplate repository factory and factory bean implementation.

DefaultRepositoryInformation now makes target class methods assignable before caching and returning them, so that they can always be invoked reflectively. Made this aspect part of the contract of RepositoryInformation.getTargetClassMethod(…).
2015-05-04 14:31:59 +02:00
Oliver Gierke
cb78260322 DATAREST-684 - ProxyProjectionFactory now exposes target instance on proxy.
Changed TargetClassAware to TargetAware and expose the actual proxy target for framework purposes.
2015-04-15 20:42:34 +02:00
Oliver Gierke
9977c61667 DATACMNS-683 - Tweaked the matching algorithm for DomainClassConverter.
DomainClassConverter as well as its internal ToEntity- and ToIdConverter implementations now actively refrain from matching if the source type is assignable to the target one to prevent unnecessary conversion attempts if the source value already actually is assignable to the target type.

Related ticket: DATACMNS-583.
2015-04-13 17:40:40 +02:00
Oliver Gierke
d48fddf9e6 DATACMNS-681 - Removed some compiler warnings.
Removed unused constants. Removed usage of deprecated method in RepositoryBeanDefinitionParser.
2015-04-13 13:04:59 +02:00
Oliver Gierke
e3df8907fb DATACMNS-678 - Improved RepositoryInvoker.invokeQueryMethod(…).
Introduced a new overload for invokeQueryMethod(…) that uses a MultiValueMap with effective values of type Object so that clients can hand non-String values to the invocation. This is particularly useful if certain values shall trigger dedicated Converters registered in the ConversionService of ReflectionRepositoryInvoker.

Related tickets: DATAREST-502.
2015-04-07 16:43:01 +02:00
Oliver Gierke
b0211911b5 DATACMNS-677 - AnnotationBasedPersistentProperty now caches absence of annotations on accessor-only properties.
AnnotationBasedPersistentProperty now also caches the absence of properties that are expressed through accessors only. Previously the absence of a field caused us to skip the registration of the absence in the cache.
2015-04-07 08:44:30 +02:00
Oliver Gierke
ffbaeddedb DATACMNS-613 - Removed custom CollectionFactory after upgrade to Spring 4.1. 2015-03-31 17:13:37 +02:00
Oliver Gierke
1c175ef59b DATACMNS-673 - Enhanced RepositoryMetadata to allow returning alternative domain types.
In case a RepositoryMetadata implementation alters the domain type the repository is actually handling, we still have to be able to find the repository based on the type originally declared in the repository.

The newly introduced getAlternativeDomainTypes() is now used by Repositories to register a repository for all types returned by that method, too, so that this reverse lookup still works.
2015-03-31 16:30:39 +02:00
Oliver Gierke
53d19c72c3 DATACMNS-663 - Fixed typo in BytecodeGeneratingEntityInstantiator. 2015-03-27 12:33:13 +01:00
Thomas Darimont
6f7d8489bf DATACMNS-654 - Polishing.
Added missing documentation for geospatial return types.
Fixed typo in GeoResult JavaDoc.
2015-03-23 11:13:36 +01:00
Oliver Gierke
5487395397 DATACMNS-661 - Polishing.
Removed the ability to configure a custom SpElExpressionParser for now as it's not really part of the performance optimization. Polished assertions in SpelEvaluatingMethodInterceptor.

Original pull request: #118.
2015-03-19 18:57:20 +01:00
Thomas Darimont
0cf395c1b1 DATACMNS-661 - Improvements in SpelAwareProxyProjectionFactory.
We now allow a SpelExpressionParser to be configured on the SpelAwareProxyProjectionFactory. This parser is then passed on to SpelEvaluatingMethodInterceptor. We also now eagerly pre-parse any SpEL expression in @Value annotations on methods of the projection interface. This avoids repeated evaluations during the actual method invocations.

Original pull request: #118.
2015-03-19 18:57:19 +01:00
Oliver Gierke
537fc430a9 DATACMNS-660 - Web configuration support now picks up configuration annotated with @SpringDataWebConfigurationMixing.
Introduced @SpringDataWebConfigurationMixing that can be used on configuration classes that are supposed to contribute components to the Application context when @EnableSpringDataWebSupport is used.

SpringDataWebConfigurationImportSelector scans the org.springframework.data package for classes annotated with that annotation and adds them to the classes to be considered config classes.
2015-03-17 17:08:31 +01:00
Oliver Gierke
d7adfbd859 DATACMNS-656 - Make application of default transactions configurable on TrasnactionalRepositoryFactoryBeanSupport.
TrasnactionalRepositoryFactoryBeanSupport now exposes a setEnableDefaultTransactions(…) which, if disabled, causes the TransactionalRepositoryProxyPostProcessor not to be registered and thus no default transactions to be applied.

Related tickets: DATAJPA-685.
2015-03-10 19:18:28 +01:00
Oliver Gierke
57180568c5 DATACMNS-655 - Invoking default methods on projection proxies now works.
Extracted DefaultMethodInvokingMethodInterceptor from RepositoryFactorySupport and register it within ProxyProjectionFactory if the code is running on Java 8.

Original pull request: #117.
2015-03-10 11:47:12 +01:00
Oliver Gierke
e2a7057af9 DATACMNS-652 - Removed JDK 8 reference from TypeDiscoverer.
Removed accidentally introduced reference to JDK 8's Executable as common super type of Constructor and Method.
2015-03-05 17:14:27 +01:00
Oliver Gierke
2d75cf2c43 DATACMNS-651 - Introduced a Range value type.
Primarily intended to be used with Distance instances, we introduce a Range value type. Distance now has factory methods to create Range instances between two distances. To support this, Distance now implements comparable based on the normalized value of it.

Tiny refactoring in TypeDiscoverer to avoid code duplication between the lookup of parameter type information for constructors and methods.
2015-03-04 17:34:32 +01:00
Oliver Gierke
186cb25605 DATACMNS-650 - Polishing.
Added stream to the list of supported query method prefixes. Allow Stream to be used as return type for paginating queries, too.

Renamed Java8StreamUtils to StreamUtils. Some additional JavaDoc.

Original pull request: #116.
2015-03-03 18:10:40 +01:00
Thomas Darimont
e92c235fdf DATACMNS-650 - Introduced CloseableIterator abstraction as a foundation for streaming of results.
A CloseableIterator abstracts the underlying result with support for releasing the associated resources via close() which can be transparently be used with try-with-resources in Java 7 since Closeable implements AutoCloseable from Java 7 on upwards. Added detector methods to QueryMethod to check whether the current method returns a Stream. 

Introduced ReflectionUtils.isJava8StreamType to safely detect whether the given type is assignable to a Java 8 Stream. Introduced CloseableIteratorDisposingRunnable that can be registered as a cleanup action on a Stream.

Original pull request: #116.
2015-03-03 16:08:00 +01:00
Thomas Darimont
ec643d21cb DATACMNS-554 - Added QueryDslPredicateExecutor.findAll(Predicate, Sort).
We now support findAll on QueryDslPredicateExecutor that accepts a Querydsl Predicate and a Sort.

Original pull request: #115.
2015-02-24 09:40:16 +01:00
Oliver Gierke
0c65c7bb67 DATACMNS-638, DATACMNS-643 - Support for JSR-310 and ThreeTen datetime types.
Extend AuditableBeanWrapper to allow access to the last modification date of a target object. Made AuditableBeanWrapperFactory an interface and renamed what’s been previously known under this name as DefaultAuditableBeanWrapperFactory.

The components previously relying on a MappingContext to lookup a PersistentEntity now use PersistentEntities to be able to back a collection of MappingContexts behind that and also avoid unmanaged types to be added to the MappingContext.

We now also register the JSR-310 and ThreeTen back-port converters with the ConversionService to be able to get and set auditing dates as these types.
2015-02-04 19:30:02 +01:00
Oliver Gierke
fe49e4cf14 DATACMNS-642 - Avoid setter lookup in BeanWrapper for if field access is used.
We now delay the lookup of the setter method until we discover we really  need to use property access.
2015-02-04 17:11:48 +01:00
Oliver Gierke
bff8caba75 DATACMNS-641 - Order clauses in derived repository clauses now default to ascending order.
OrderBySource now considers the Asc and Desc keywords in an OrderBy-clause optional defaulting to ascending order as Sort defaults to anyway.
2015-02-04 12:06:58 +01:00
Oliver Gierke
2b4d173320 DATACMNS-640 - Fixed potential NullPointerException in PageableHandlerMethodArgumentResolver.
We now double check the fallback Pageable for being null before trying to lookup the Sort to fall back.
2015-02-04 10:32:17 +01:00
Oliver Gierke
57a42ababd DATACMNS-630 - Added HandlerMethodArgumentResolver to create proxies for interfaces.
We now ship a ProxyingHandlerMethodArgumentResolver that gets registered when @EnableSpringDataWebSupport is activated. It creates Map-based proxy instances for interfaces used as Spring MVC controller method parameters.
2015-01-30 15:15:55 +01:00
Thomas Darimont
0fb572b550 DATACMNS-636 - Add QueryDslPredicateExecutor.exists(…) which accepts a Querydsl predicate.
Original pull request: #112.
2015-01-26 11:03:13 +01:00
Oliver Gierke
df9f8c417e DATACMNS-637 - Performance improvements.
Made ObjectInstantiator interface public as otherwise the generated class to implement it cannot access it and thus the usage of the ByteCodeGeneratingEntityInstantiator fails completely.

PreferredConstructor.isEnclosingClassParameter(…) now eagerly returns if the parameter itself is not an enclosing one and thus avoids a collection lookup and equals check. Moved equals check for the type to the very end of the equals check to increase the chances that other inequality guards kick in earlier.

AbstractMappingContext now leaves the non-null-check for getPersistentEntity(…) to the factory method of ClassTypeInformation.

We now pre-calculate the hash codes for TypeInformation implementations as far as possible as the instances are used as cache keys quite a lot. The same applies to AbstractPersistentProperty.

BasicPersistentEntity now uses an ArrayList we sort during the verify() phase to mimic the previous behavior wich was implemented using a TreeSet as ArrayLists are way more performant when iterating over all elements which doWithProperties(…) is doing which is used quite a lot.

BeanWrapper now avoids the getter lookup if field access is used.

SimpleTypeHolder now uses a CopyOnWriteArrySet to leniently add types detected to be simple to the set of simple types to avoid ongoing checks against the inheritance hierarchy.
2015-01-25 17:43:59 +01:00
Oliver Gierke
5cc4811c52 DATACMNS-635 - Slice and Page can now be mapped using a Converter.
Introduced a map(Converter converter) method on Slice and Page to be able to easily transform the elements and create a new Slice or Page of the transformation result.

On Java 8 this allows code like this:

Page<String> strings = …;
Page<Integer> ints = strings.map(String::length);
2015-01-22 19:01:16 +01:00
Oliver Gierke
2c772d60de DATACMNS-634 - Polishing.
Simplified type traversal in Repositories.getRepositoryFactoryInfoFor(…) and unit tests.

Original pull request: #110.
2015-01-20 17:53:33 +01:00
Thomas Eizinger
9f21cc2f28 DATACMNS-634 - Repositories now als returns repositories for super types of a domain class.
In case the repository lookup for a given domain type fails we traverse the given types super-types and try to detect a repository for those.

Original pull request: #110.
2015-01-20 17:53:20 +01:00
Oliver Gierke
b2251aa5b9 DATACMNS-621 - Polishing.
Simplified implementation of Path conversion. Inlined helper domain types to not to pollute the packages with types that are only used within that very one test class.

Original pull request: #111.
2015-01-20 16:31:30 +01:00
Christoph Strobl
95bda862e7 DATACMNS-621 - QSort now treats nested paths correctly.
We now inspect intermediate path elements to build sort order accordingly.

Original pull request: #111.
2015-01-20 16:25:52 +01:00
Oliver Gierke
2e62a16f69 DATACMNS-631 - Made RepositoryFactorySupport.getRepositoryMetadata(…) protected.
Some JavaDoc polishes.
2015-01-15 15:46:26 +01:00
Oliver Gierke
a98d5c7ec6 DATACMNS-630 - Integrate projection infrastructure from Spring Data REST.
Ported the projection infrastructure previously residing in Spring Data REST and extended it by defaulting to a Map-backed source to store and retrieve data.

Separated out the SpEL based functionality mostly for SOC-reasons and easier testability.

Related tickets: DATAREST-437, DATACMNS-618, DATACMNS-89.
2015-01-11 19:35:31 +01:00
Oliver Gierke
9d3fab5e41 DATACMNS-628 - Polishing.
Renamed converter to ThreeTenBackPortConverter to better reflect the project we're integrating with.
2015-01-05 18:14:46 +01:00
Oliver Gierke
047d883371 DATACMNS-627 - DomainClassConverter is able to translate into identifier types, too.
Extended the implementation of DomainClassConverter to also support converting domain types into their identifier types and transitively convertible types.
2015-01-05 18:08:37 +01:00