Commit Graph

252 Commits

Author SHA1 Message Date
Oliver Gierke
55d988e7b7 DATACMNS-615 - PageImpl now rejects a total less than the amount of items given.
PageImpl now makes sure that the total given to the constructor is never less than then number of items given to make sure we do not mask broken count calculation by creating an actually invalid instance.

Related ticket: DATAMONGO-1120.
2014-12-16 12:40:48 +01:00
Oliver Gierke
c343a65632 DATACMNS-611 - Improved cache lookups in RepositoryInterfaceAwareBeanPostProcessor.
Refactored predictBeanType(…) to only look up the predicted cached type once.

Related pull request: #108.
2014-12-08 17:51:17 +01:00
Oliver Gierke
d8781888d8 DATACMNS-610 - Extracted QueryExecutionResultHandler from RepositoryFactorySupport.
To be able to verify the conversion of List based query execution results into Sets I extracted a QueryExecutionResultHandler that applies the already implemented handling for Optional types and eventually general prost processing in case the return type declared at the repository query method doesn't match the returned value.

Added additional unit tests for Optional handling.
2014-12-04 20:35:39 +01:00
Oliver Gierke
5b1b73b297 DATACMNS-609 - Polishing in RepositoryConfigurationExtensionSupport.
RepositoryConfigurationExtensionSupport.registerBeansForRoot(…) now hands the extracted source of the configuration to the bean registration for the RepositoryInterfacePostProcessor.
2014-12-02 23:36:19 +01:00
Oliver Gierke
6677612f8e DATACMNS-609 - Improved bean definition registration for repository configuration.
The bean definitions that were registered for a repository configuration setup we registered once for every usage of the repository configuration element (annotation or XML). This caused multiple registrations of the very same bean definition which - as in case of the RepositoryInterfaceAwareBeanPostProcessor - apparently leads to performance problems in the container startup. Feedback for the latter claim is already asked for but we improved the registration setup nonetheless.

Introduced a registerIfNotAlreadyRegistered(…) method on RepositoryConfigurationExtensionSupport to allow easy registration of to-b-registered-once-and-only-once beans. We now hint towards the newly introduced method in registerWithSourceAndGeneratedBeanName(…).
2014-12-01 10:17:11 +01:00
Oliver Gierke
90a9462221 DATACMNS-587 - Added findAll(OrderSpecifier… orders) to QueryDslPredicateExecutor.
QueryDslPredicateExecutor now has a findAll(…) method to take multiple OrderSpecifiers to order the results. Polished JavaDoc along the way.
2014-11-28 10:02:19 +01:00
Oliver Gierke
fea5b1c439 DATACMNS-607 - Introduced AnnotationAttributes and MethodParameters from Spring HATEOAS to avoid dependency. 2014-11-27 18:34:18 +01:00
Oliver Gierke
a5df8d92a7 DATACMNS-606 - Added converters for JSR-310 types.
Added Jsr310Converters to contain converters to map between Date and JDK 8 date/time types.
2014-11-27 14:54:41 +01:00
Oliver Gierke
bb6ec38541 DATACMNS-605 - Moved key-value infrastructure to dedicated project. 2014-11-27 14:17:27 +01:00
Thomas Darimont
5448b3e63b DATACMNS-604 - Move QueryDsl helper methods from QueryDslUtils to KV package.
Moved to new class KeyValueQueryDslUtils in order to avoid class loading issues.

Original pull request: #107.
2014-11-27 12:29:34 +01:00
Oliver Gierke
cb884eb0cd DATACMNS-525 - Removed EhCache implementation.
Original pull request: #25.
2014-11-26 17:09:10 +01:00
Oliver Gierke
499182f4c9 DATACMNS-525 - Removed Hazelcast implementation.
Original pull request: #95.
2014-11-26 17:09:10 +01:00
Christoph Strobl
52108ed006 DATACMNS-525 - Add KeyValuePersistenceExceptionTranslator, fixing Todos.
Added key/value specific PersistenceExceptionTranslator and use it within KeyValueTemplate. Fixed some todos in JavaDoc and added missing tests. Renamed test class for SimpleKeyValueRepository according to the changed name.

Original pull request: #95.
2014-11-26 17:09:07 +01:00
Oliver Gierke
1f71a28408 DATACMNS-525 - Polishing.
Extracted KeySpaceUtils from KeyValueTemplate and pulled in the copy of MetaAnnotationUtils to hide it from the outside. Separated related test cases into dedicated test class.

Renamed BasicMappingContext to KeyValueMappingContext and BasicPersistentProperty to KeyValuePersistentProperty. Fixed spelling in SpelQueryCreatorUnitTests.

Moved MappingContext into separate package to satisfy architectural guidelines. Created dedicated KeyValueRepositoryNamespaceHandler to avoid a circular reference between commons and the key-value subsystem.

Made the query creator type an annotation on @EnableKeyValueRepositories so that it's not exposed to the user to be configured. Added the necessary ImportBeanDefinitionRegistrars to the Hazelcast and EhCache implementation. Removed @since tags from those modules at they're not going to make it into Spring Data Commons. Renamed EnableEhCacheRepsotoriesUnitTests to EnableEhCacheRepositoriesIntegrationTests as well as the same for the Hazelcast specific test.

The KeyValueRepositoryConfigurationExtension now explicitly registers a KeyValueMappingContext unless one is already registered. AnnotationRepositoryConfigurationSource now explicitly exposes an AnnotationMetadata instance for the annotation that triggered the configuration.

Turned SpelCriteriaAccessor and SpelPropertyComparator into classes to be able to pass them a SpelExpressionParser to be able to get rid of SpelExpressionFactory eventually. Made both classes as well as SpelQueryEngine package protected for now.

Moved repository implementations into support package. Updated architcture description JavaDoc polish, spacing, blank lines. Added TODOs.

Original pull request: #95.
2014-11-26 16:47:01 +01:00
Christoph Strobl
e2358f3bf8 DATACMNS-525 - Introduce infrastructure for KeyValue repositories.
Added basic infrastructure for repositories on top of key-value data stores. For more details see the original pull request.

Original pull request: #95.
2014-11-26 16:43:15 +01:00
Oliver Gierke
e1b38faee9 DATACMNS-601 - Fixes for most of the SonarQube warnings. 2014-11-26 09:25:14 +01:00
Oliver Gierke
9a1879617e DATACMNS-600 - Moved RepositoryInvoker subsystem into support package. 2014-11-25 11:34:16 +01:00
Oliver Gierke
5d9b89c339 DATACMNS-591 - RepositoryConfigurationDelegate now uses Environment and ResourceLoader everywhere.
We now also use the Environment and ResourceLoader for the component scan to detect whether multiple Spring Data modules are on the classpath.
2014-11-24 22:38:48 +01:00
Oliver Gierke
4c1a187dd4 DATACMNS-599 - Introduced IdentifierAccessor API.
PersistentEntity now exposes an getIdentifierAccessor(…)-method that allows obtaining the identifier of an entity without using a PersistentProperty instance. This allows advanced scenarios (like multi-property identifiers). Also we can use store specific means to optimize id lookups to e.g. avoid proxy initialization for lazy loading proxies.
2014-11-24 13:01:23 +01:00
Oliver Gierke
2388b6fa90 DATACMNS-597 - Fixed to strict consistency check in PersistentPropertyAccessor lookup.
BasicpersistentEntity now allows subtypes to be handed into the PersistentPropertyAccessor lookup to support inheritance hierarchies as well as interface based PersistentEntity scenarios.
2014-11-19 17:05:50 +01:00
Oliver Gierke
3446c457d5 DATACMNS-596 - Polishing.
PersistentEntityInformation now falls back to null values for PersistentEntity instances that don't expose an identifier property.
2014-11-18 16:46:18 +01:00
Oliver Gierke
6a849bc8ef DATACMNS-596 - Introduced PersistentPropertyAccessor.
To be able to customize the lookup of bean properties by persistent store we now expose a getPropertyAccessor(Object entity) method on PersistentEntity. It returns a PersistentPropertyAccessor which is basically an interface with a simplified API of BeanWrapper.

Reduced the plain BeanWrapper to not perform any type conversion to be able to drop the ConversionService dependency. To compensate for that we introduced a ConvertingPropertyAccessor that takes a ConversionService and delegates to a standard PersistentPropertyAccessor and applies conversions if necessary.

Refactored client APIs to use the PersistentPropertyAccessor instead of referring to BeanWrapper directly. Deprecated BeanWrapper.create(…) for removal in RC1.
2014-11-18 12:29:30 +01:00
Oliver Gierke
93dbc26969 DATACMNS-589 - Polishing.
Made DefaultCrudMethods public to support better testing. Components that are based on CrudMethods can be tested easier if DefaultCrudMethods is public, so that an instance can easily be set up by using a DefaultRepositoryMetadata instance.

Polished JavaDoc and copyright headers.
2014-11-14 16:53:17 +01:00
Oliver Gierke
c5721cfc0c DATACMNS-594 - Fixed creation of type variable map to extend into detected bounds.
The initial setup of the type variable map now unfolds the detected types in the map to make sure we detect all type variables present in the current scope.

Added caching of component and map value TypeInformation instances to avoid repeated creation.
2014-11-14 16:34:31 +01:00
Oliver Gierke
eac6fcaa8e DATACMNS-589 - Integrated RepositoryInvoker abstraction from Spring Data REST.
Replaced CrudInvoker with the more sophisticated and flexible RepositoryInvoker originating from Spring Data REST. Slightly refined the API and added a lot more unit tests. Refactored usage of CrudInvoker to use a DefaultRepositoryInvokerFactory and create RepositoryInvokers for the domain types.
2014-11-14 15:45:42 +01:00
Oliver Gierke
ac73720668 DATACMNS-590 - Fixed calculation of nested generics in ParentTypeAwareTypeInformation.
So far, the lookup of the type variable map was preferring the type variable maps detected on parent types in nested structures. This caused the concrete type variables in nested types not being considered correctly which caused the type resolution to fall back to the generic bounds.

We now accumulate the type variable maps to avoid having to lookup a certain map in the nesting hierarchy. The core fix is in ParentTypeAwareTypeInformation's constructor and mergeMaps(…) respectively. Simplified the handling of type variable maps and made proper use of generics throughout the class hierarchy.
2014-11-12 14:30:34 +01:00
Thomas Darimont
dec5cadce9 DATACMNS-581 - Add support for NotContaining keyword for derived repository queries.
We now support the keyword NotContaining in query methods for repositories. This is achieved by adding NOT_CONTAINING to the Part.Type enum with the variants 'IsNotContaining', 'NotContaining', 'NotContains'. Added a dedicated toString() method to ease debugging to Part.Type.

Original pull request: #100.
2014-10-29 09:50:02 +01:00
Thomas Darimont
c898f1ec7b DATACMNS-583 - DomainClassConverter returns input if given types are the same.
DomainClassConverter now returns input when the source type is identical to the target type. Previously we erroneously tried to convert the sourceType to the idType of the targetType's backing repository. As a side effect we also avoid performing some unnecessary converter hops.

Original pull request: #101.
2014-10-29 09:41:14 +01:00
Oliver Gierke
28b7e0439d DATACMNS-578 - Polishing.
Added some JavaDoc where missing. Better variable names and slightly parameter ordering changes. Formatting in the unit tests and reference to the original ticket.

Original pull request: #98.
2014-10-21 12:18:01 +02:00
Thomas Darimont
1b9cdc941f DATACMNS-578 - Speed up instance creation by generating factory classes with ASM.
Introduced BytecodeGeneratingEntityInstantiator which dynamically generates classes to speed up the dynamic instantiation of objects. Since we cannot support every use case with byte code generation we gracefully fallback to the ReflectiveEntityInstantiator.

BytecodeGeneratingEntityInstantiator has support for unboxing of constructor parameters and more robust handling for cases where we cannot generate a custom ObjectInstantiator.

Original pull request: #98.
2014-10-21 12:18:01 +02:00
Thomas Darimont
48966b50d6 DATACMNS-577 - Improved JavaDoc on QueryDslPredicateExecutor.
Clarified return values if predicates don't match or return multiple results (for the findOne(…) method). Copied summary to the @return tag.

Original pull request: #96.
2014-10-08 06:46:55 +02:00
Thomas Darimont
ad7a87403d DATACMNS-530 - Improve JavaDoc for RepositoryConfigurationSourceSupport.
Removed misleading JavaDoc.

Original pull request: #97.
2014-10-07 15:01:30 +02:00
Mark Paluch
6cc9e33359 DATACMNS-565 - Improved detection of custom implementations for CDI repositories.
The detection of the custom implementation has now been moved into the Bean base class to avoid calls to BeanManager.getBeans(…) (which are necessary to pick up the configuration class defining postfixes and the like) happen to early in the CDI container lifecycle.

Related ticket: DATACMNS-557.
2014-09-01 12:46:12 +02:00
Thomas Darimont
9fc57ea3bf DATACMNS-566 - Allow sorting by QueryDsl operator expressions.
Previously we only allowed to sort by QueryDsl path expressions. With this change we now also support ordering by operator expressions, e.g. yearMonth() on a date property.

Original pull request: #94.
2014-08-26 13:56:17 +02:00
Oliver Gierke
c9dd679cd1 DATACMNS-562 - AbstractPersistentProperty doesn't consider maps and collections entities anymore.
The type detection for entity candidates of PersistentProperty instances now consistently handles collection types even if they're used als collection or map values.
2014-08-19 17:53:51 +02:00
Oliver Gierke
5352701374 DATACMNS-556 - Make annotation validation in AnnotationBasedPersistentProperty more lenient.
Annotations used on both fields and accessors are now only rejected if they're Spring Data annotations (i.e. from the org.springframework.data namespace) and the configurations of these annotations differ.
2014-08-10 13:15:39 +02:00
Oliver Gierke
3660676338 DATACMNS-558 - Some code cleanups according to the Sonar report. 2014-08-10 12:51:28 +02:00
Oliver Gierke
756c951112 DATACMNS-557 - Polishing.
Renamed CdiRepositoryConfigurationSource to CdiRepositoryConfiguration. Turned anonymous inner default implementation into dedicated enum to avoid repeated instantiation.

Changed the CdiRepositoryBean to rather take a Bean instance of the custom implementation instead of the resolved object to make sure both instances (the custom implementation and the repository proxy) are instantiated at the same time.

Fixed imports. Some early returns to avoid unnecessary nesting.

Adapted architecture description to allow CDI module accessing the configuration module.

Related pull request: #92.
2014-08-07 12:33:29 +02:00
Mark Paluch
1f0260e48d DATACMNS-557 - Added support for custom implementations to CDI infrastructure.
The CDI extension now discovers a custom implementation class similarly to the detection when using Spring Data in a Spring container. Extracted the custom implementation detection for re-use. The CDI extension discovers the potentially available bean and hands it to the CdiRepositoryBean for further usage.

Implementations should implement the extended variant of the create(…) method we introduce with this commit to be able to forward the resolved custom implementation bean.

Original pull request: #92.
2014-08-07 12:05:09 +02:00
Oliver Gierke
85157b6644 DATACMNS-526 - Added type matching to strict repository scanning.
Repository interfaces are now also considered strict matches if they are assignable to one of the types returned by getIdentifyingTypes().
2014-07-31 12:54:08 +02:00
Oliver Gierke
81af5ee730 DATACMNS-526 - Improved configuration behavior in multi-store scenarios.
We now apply a stricter repository interface selection if we detect multiple Spring Data modules to be in the classpath to avoid the repository scanning accidentally overriding each others definitions or even picking up interfaces they weren't intended to manage.

The detection is based on a type scan in dedicated base package where subtypes of RepositoryFactorySupport usually reside. If more than one type is found, we activate strict scanning.

The strict check is actually implemented in RepositoryConfigurationExtensionSupport to be accessible for store implementations. By default we try to load the repository candidate interface and inspect the managed domain types for a collection of annotations (see RepositoryConfigurationExtensionSupport.getIdentifyingAnnotations()). Implementors still have the chance to customize the behavior by overriding isStrictRepositoryCandidate(…).

We also introduced a getModuleName() to be able to create better logging output in terms of repository registration. Moved registration of RepositoryConfigurationExtension as Spring bean into the base types for XML and annotation configuration support to make sure they only kick in if explicit configuration is used.
2014-07-28 19:56:40 +02:00
Oliver Gierke
3bcf6f3f27 DATACMNS-547 - @TypeAlias is now @Persistent.
For @TypeAlias annotated types being picked up using entity scanning, the annotation is now @Persistent.

Related tickets: DATAMONGO-992.
2014-07-24 14:13:10 +02:00
Oliver Gierke
ba70380555 DATACMNS-546 - PropertyPath has better exception messages now.
PropertyPath now exposes the complete property named the resolution failed for in case it can't resolve a source String. It will expose the part of the Path from the deepest successful resolution result.

Changed the resolution algorithm to use a List instead of a Stack and a fresh instance of the former so that the nested recursion steps keep track of the correct resolution depths.
2014-07-21 18:11:12 +02:00
Oliver Gierke
5bc89af4e7 DATACMNS-544 - Indicate repository configuration has been active.
RepositoryConfigurationDelegate now registers the store-specific RepositoryConfigurationExtension as lazy-init BeanDefinition so that other parties can detect that definition.
2014-07-18 20:02:49 +02:00
Oliver Gierke
5aa5b9e1aa DATACMNS-543 - Avoid duplicate repository bean registration in XML namespace.
We're now firing the component registration event manually in RepositoryBeanDefinitionParser as ParserContext.registerBeanComponent(…) registers the given BeanComponentDefinition with the registry. As we do that manually before this previously resulted in the BeanDefinition overriding the very same one and container warnings in turn.
2014-07-18 12:21:35 +02:00
Oliver Gierke
ed0f7c51f8 DATACMNS-469 - Removed deprecations. 2014-07-16 11:53:20 +02:00
Oliver Gierke
789f620af1 DATACMNS-539 - DefaultCrudMethods now detects delete(T t) methods.
The CRUD method detection now also discovers delete methods taking the domain type as argument.

Related ticket: DATAREST-319.
2014-07-15 10:37:29 +02:00
Oliver Gierke
94436dd609 DATACMNS-533 - Implemented handling of root objects.
Refactored the implementation of the dynamic lookup of properties and functions on EvaluationContextExtensions. All the reflective lookup logic has moved into an EvaluationContextExtensionAdapter.

We now also distinguish between the meta-information that can be looked up once and cached (so that we avoid reflection overhead for subsequent context creations).

Related pull request: spring-projects/spring-data-jpa#101
Related ticket: DATAJPA-564
2014-07-10 12:21:12 +02:00
Thomas Darimont
1e489bbd6d DATACMNS-533 - Added test cases for root object integration in SpEL extension API.
Changed SPI to expose a Function type rather than plain methods as well as an arbitrary root object.

Related pull request: spring-projects/spring-data-jpa#101
Related ticket: DATAJPA-564
2014-07-10 12:20:59 +02:00
Oliver Gierke
39f028bb6c DATACMNS-533 - Polishing of special parameter handling.
Collapsed variable gathering methods into one, make sure we expose all values (also null ones). Renamed unit test for ExtensionAwareEvaluationContextProvider according to the class name. Some further cleanups in the test case.

Related pull request: spring-projects/spring-data-jpa#101
Related ticket: DATAJPA-564
2014-07-10 12:20:49 +02:00