Commit Graph

369 Commits

Author SHA1 Message Date
Nick Williams
98b8129a74 DATACMNS-357 - Added support for primitive ids in EntityInformation.
AbstractEntityInformation now detects primitive id types and adapts the isNew state according to the Java Language Specification §4.12.5. Supported are primitive Numbers and the entity is considered new if the value of the primitive field is zero.

Original pull request: #37.
2013-08-14 09:38:17 +02:00
Oliver Gierke
b059da8f4f DATACMNS-341 - RepositoryFactory(Bean)Support is now class loader aware.
Let both RepositoryFactorySupport and RepositoryFactoryBeanSupport implement BeanClassLoaderAware to pick up the ClassLoader used by the container. The latter class forwards the configured instance into the factory it creates.
2013-08-12 10:49:36 +02:00
Thomas Darimont
7b5bdd45e6 DATACMNS-304 - JavaDoc fix for PageableArgumentResolver.
The deprecation hint in PageableArgumentResolver now points to PageableHandlerMethodArgumentResolver.

Original pull request: #38.
2013-08-12 09:30:32 +02:00
Oliver Gierke
59a8cd5566 DATACMNS-352 - Aligned setter names for argument resolvers for Pageable and Sort.
PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now consistently use set*ParameterName(…) and setQualifierDelimiter(…) for configuration.

Added some more unit tests to verify invalid configuration get rejected.
2013-08-08 12:52:11 +02:00
Oliver Gierke
541ef648f1 DATACMNS-356 - Parameters now uses DefaultParameterNameDiscoverer if present.
We now leniently try to lookup DefaultParameterNameDiscoverer and create an instance of it to make use of Spring 4's improved parameter name capabilities on Java 8. We fall back on a LocalVariableTableParameterNameDiscoverer if on Spring versions prior to 4.
2013-08-07 14:39:37 +02:00
Oliver Gierke
04d6859354 DATACMNS-355 - ReflectionAuditingBeanWrapper now uses a ConversionService.
We're not manually converting the DateTime instance into the user field type but delegate to a ConversionService instance. This will allow us to automatically adhere to enhancements in conversion capabilities to the DefaultConversionService.
2013-08-07 13:48:19 +02:00
Thomas Darimont
a63a2bbd75 DATACMNS-351 - Add setFallbackSort(…) to SortHandlerMethodArgumentResolver.
SortHandlerMethodArgumentResolver now has a setFallbackSort(…) to be able to configure the Sort instance to be used if nothing can be resolved from the request and sort default is configured on the controller method.

Renamed name of getDefaults(…) method in SortHandlerMethodArgumentResolver to getDefaultFromAnnotationOrFallback(…) and refactored implementation to be more understandable.

Original pull request: #36
2013-08-07 12:29:05 +02:00
Oliver Gierke
b8e457db9b DATACMNS-350 - Improved extensibility of Parameters.
Parameters is now a class explicitly designed for extension using generics. We provide a new DefaultParameters which is essentially a drop in replacement for former Parameters as it exposes individual Parameter instances.

Modules that previously extended Parameters will now have to implement the abstract factory methods exposed to create concrete - and potentially customized - Parameter instances.
2013-07-30 15:02:51 +02:00
Thomas Darimont
cc576a7398 DATACMNS-349 - Opened up SPI in DefaultTypeMapper to allow subclasses to resolve TypeAliases.
Added getAliasFor(TypeInformation) method in DefaultTypeMapper to allow subclasses to resolve TypeAliases.
2013-07-23 13:21:59 +02:00
Thomas Darimont
2afb570729 DATACMNS-345 - Use the actual type of the persistent property.
Changed getPersistentEntity(PersistentProperty<?>) to return the actual type of the persistent property in order to deal with collection and map types transparently.

Original pull request: #31.
2013-07-16 12:42:31 +02:00
Oliver Gierke
634789c3b7 DATACMNS-344 - Allow Repositories to work with non-CrudRepositories.
Introduced CrudMethods abstraction obtainable via a RepositoryInformation to inspect a repository for the presence of individual CRUD methods. The default implementation favors more special methods (e.g. the findAll(Pageable) over a simple findAll()). Introduced a CrudInvoker to be able to easily invoke findOne(…) and save(…) independently of whether the target methods are declared explicitly or inherited from CrudRepository.

Fixed some test case names to make sure they're executed during the Maven build.
2013-07-15 15:02:32 +02:00
Oliver Gierke
8a02b4ad6e DATACMNS-343 - PageableHandlerMethodArgumentResolver replaces pagination parameters now.
PageableHandlerMethodArgumentResolver now uses replaceQueryParam(…) to make sure the query parameters necessary for pagination don't accidentally get added multiple times.
2013-07-12 12:53:14 +02:00
Thomas Darimont
fc5ce662af DATACMNS-342 - Open up id property selection API in BasicPersistentEntity.
To support more advanced id property selection mechanisms we introduced a callback method returnPropertyIfBetterIdPropertyCandidate(…).

Pull request: #30.
2013-07-08 12:07:21 +02:00
Oliver Gierke
3a496b1f44 DATACMNS-337 - PersistentProperty now exposes getActualType().
The call transparently resolves map value types and collection component types if the property is either one of them.
2013-06-10 15:01:39 +02:00
Oliver Gierke
3f41810b86 DATACMNS-336 - Config classes backing @EnableSpringDataWebSupport are now public. 2013-06-10 14:12:42 +02:00
Oliver Gierke
15c4e34716 DATACMNS-335 - PageableHandlerMethodArgumentResolver now has configurable max page size.
The default is set to 2000.
2013-06-10 14:11:26 +02:00
Oliver Gierke
e0dda2a4f0 DATACMNS-333 - Added Jackson 2 support to repository populators.
Added necessary infrastructure to use Jackson 2 with repository populators. Expose a jackson2-populator XML element in the namespace to setup a Jackson2 based repository populator.
2013-05-29 17:51:39 +02:00
Oliver Gierke
cd2ea03928 DATACMNS-332 - Further performance improvements.
Reverted from ConcurrentHashMap to plain HashMap where concurrency wasn't an issue and profiling showed performance hotspots. Introduced caches for ParameterizedTypeInformation.getComponentType() and the resolved raw type in TypeDiscoverer.
2013-05-23 18:57:48 +02:00
Oliver Gierke
905565cbcc DATACMNS-332 - Cache AnnotationBasedPersistentProperty.isTransient(). 2013-05-23 10:03:05 +02:00
Oliver Gierke
24bc432d48 DATACMNS-332 - AbstractMappingContext now prefers most concrete property.
BasicPersistentEntity now only caches the most concrete property for a by-name lookup to mimic the behavior that was implemented in getPersistentProperty(String name). This is to prevent shadowed properties of superclasses leaking into the by-name lookups.

Improved AbstractPersistentProperty.toString() to rather render the concrete field it is backed by.
2013-05-22 18:37:51 +02:00
Oliver Gierke
73b9d60be5 DATACMNS-330, DATACMNS-331 - More improvements on web configuration.
Reverting the registration of the DomainClassConverter as a Spring bean an prefer direct registration against the FormatterRegistry handed into addFormatters(…) of WebMvcConvfigurerAdapter. Otherwise we run into CGLib issues while enhancing the config classes.
2013-05-22 10:18:26 +02:00
Oliver Gierke
16c3c15204 DATACMNS-330, DATACMNS-331 - Improved web configuration support.
Updated backing implementation of @EnableSpringDataWebSupport to use WebMvcConfigurerAdapter instead of WebMvcConfigurationSupport as the latter is a very custom beast in terms of configuration. Let the Spring HATEOAS specific configuration class extend the default one to register additional components. The default one accesses the FormattingConversionService through a qualified autowiring. It issues a warning in case none has been configured and asks the user to enable Spring MVC.

Updated Sonargraph architecture description to allow logging from web config layer.
2013-05-21 17:10:13 +02:00
Oliver Gierke
a9abb40fbd DATACMNS-332 - Performance improvements in conversion subsystem hotspots.
Added caching to DefaultTypeMapper, SimpleTypeInformationMapper, BasicPersistentEntity and PreferredConstructor as these seem to be performance hotspots on the reading side of object conversion.
2013-05-17 13:58:14 +02:00
Oliver Gierke
a8b912c09f DATACMNS-310 - Integrated ChainedTransactionManager from Spring Data Neo4j.
We now integrate a best-effort PlatformTransactionManager that will propagate commits and rollbacks to all PlatformTransactionManager instances registered. This assumes that the exceptional cases which will cause a rollback to happen either before the commits or during the first commit.
2013-05-15 16:34:09 +02:00
Oliver Gierke
a93c2bff94 DATACMNS-330, DATACMNS-331 - Advanced web integration.
Added PagedResourcesAssembler to easily convert Page instances into a PagedResource instance and automatically build the required previous/next links based on the 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 @EnableSpringDataWebSupport to automatically register HandlerMethodArgumentResolvers for Pageable and Sort as well as a DomainClassConverter that will allow the usage of domain types being managed by Spring Data repositories in controller method signatures. In case Spring HATEOAS is present on the classpath, we'll also register a PagedResourcesAssembler for injection as well as the appropriate HandlerMethodArgumentResolver for injection into controller methods.

Adapted Sonargraph configuration accordingly. Upgraded to Spring HATEOAS 0.6.0.BUILD-SNAPSHOT.
2013-05-15 16:03:46 +02:00
Oliver Gierke
70ce9a0908 DATACMNS-323 - PageImpl returns correct number of pages for use with content only.
So far, the PageImpl class returned 0 as total number of pages if set up from a plain List. This returns 1 now (as it should be). We've also adapted the hasNextPage() implementation to correctly calculate whether a next page is available.
2013-05-14 16:45:13 +02:00
Emanuele Blanco
602834f86a DATACMNS-328 - Fixed "fallbackPageable" typo in PageableArgumentResolver.
Pull request: #28.
2013-05-14 16:21:45 +02:00
Oliver Gierke
2c83144269 DATACMNS-327 - AbstractMappingContext implements InitializingBean again.
This causes the configured persistent entities being added to the context on its initialization instead of a delayed initialization on ApplicationContext refreshed event.
2013-05-12 23:45:11 +02:00
Oliver Gierke
8074bc87e8 DATACMNS-325 - RepositoryInterfaceAwareBeanPostProcess now implements PriorityOrdered.
This makes sure it is also applied in cases of dependency lookups for {{BeanPostProcessor}} implementation's dependencies.
2013-05-04 13:50:52 +02:00
Oliver Gierke
02cacf59bc DATACMNS-322 - CdiRepositoryBean implements PassivationCapable.
To allow the CdiRepositoryBeans being used inside scoped CDI beans we need to implement PassivationCapable so that the CDI contain can serialize the bean instance and detect the contextual instance on deserialization. As the repositories are application scoped we simply consider a bean of a given type plus its qualifier annotations unique.
2013-04-26 18:46:15 +02:00
Oliver Gierke
0cf875b358 DATACMNS-320 - Be less restrictive in finding mapping ambiguities.
So far we threw exceptions in case we find the same exception on getters *and* setters. We now allow this scenario in case the annotations are semantically equivalent.
2013-04-25 15:13:42 +02:00
Oliver Gierke
454defc637 DATACMNS-319 - Made Repositories less greedy in looking up beans.
We now don't try to eagerly lookup the beans Repositories shall capture in the constructor anymore but leniently look them up on the first request. Update tests for classes using Repositories alongside.
2013-04-25 11:20:43 +02:00
Oliver Gierke
4303fdf399 DATACMNS-318 - Refined persistence exception translation infrastructure.
Extracted the activation of persistence exception translation into a separate RepositoryProxyPostProcessor. Adapted TransactionalRepositoryFactoryBeanSupport to also register the newly introduced PersistenceExceptionTranslationRepositoryProxyPostProcessor.
2013-04-19 15:18:11 +02:00
Oliver Gierke
8a67259aef DATACMNS-236 - Fixed potential NPEs in SortHandlerMethodArgumentResolver. 2013-04-18 12:15:36 +02:00
Oliver Gierke
8d69459f74 DATACMNS-311 - TypeDiscoverer now also finds properties in type hierarchy.
We now also inspect the entire type hierarchy to lookup a property descriptor to inspect for read methods in case no field is found for a property.
2013-04-12 16:41:39 +02:00
Oliver Gierke
a7820c8cc6 DATACMNS-309 - Fixed lookup of nested properties on TypeDiscoverer.
So far the property lookup of a nested property path (e.g. "foo.bar") failed in cases the head property was not cached already. We now recursively resolve the type information even for an unpopulated cache.
2013-04-05 20:44:27 +02:00
Oliver Gierke
64dada5896 DATACMNS-306 - RepositoryBeanDefinitionBuilder not correctly sets source.
Previously, the RepositoryBeanDefinitionBuilder did not forward the repository configuration's source instance into the built BeanDefinitions. This is now fixed to enable STS track the origin of the BeanDefinition back to the configuration source (an @Enable-annotation or an XML namespace element).
2013-03-28 18:53:17 +01:00
Oliver Gierke
e8b2db8463 DATACMNS-305 - Added toString() methods to PersistentProperty implementations. 2013-03-28 15:50:17 +01:00
Oliver Gierke
fd91313f75 DATACMNS-303 - Added support for count projects in query parsing.
PartTree now supports query methods starting with "count…By" and exposes that fact through an isCountProjection() method to be used by query creators upstream
2013-03-26 14:40:23 +01:00
Oliver Gierke
31618f9198 DATACMNS-299 - Default scope of CDI repository beans to application scope.
Polished JavaDoc along the way.
2013-03-25 17:41:12 +01:00
Johannes Mockenhaupt
596908946d DATACMNS-300 - Fixed exception handling in ReflectionEntityInstantiator.
ReflectionEntityInstantiator now actually throws the wrapped exception created in the catch block handling BeanInstantiationExceptions.

Pull request: #25.
2013-03-25 13:35:09 +01:00
Oliver Gierke
9781f603ea DATACMNS-295 - Expose modify-on-creation flag in XML namespace.
Introduced additional attribute in schema in version 1.6. Added parsing of the attribute.
2013-03-21 15:44:03 +01:00
Oliver Gierke
645a605f58 DATACMNS-304 - Fixed compile error on JDK6.
Changed variable declaration in PageableHandlerMethodArgumentResolver from int to Integer to satisfy JDK6 generics resolution.
2013-03-03 15:28:09 +01:00
Kevin Raymond
a588f43857 DATACMNS-281 - Added support to Order for case insensitive sorts.
Modified the Order class to allow an ignore case flag to be set so that case insensitive sorts could be supported.
2013-02-27 15:17:21 +01:00
Oliver Gierke
b26f09f3b4 DATACMNS-291 - Fixed typo in JavaDoc of CrudRepository. 2013-02-27 14:46:17 +01:00
Oliver Gierke
e11efede4d DATACMNS-236, DATACMNS-117 - Added (Pageable|Sort)HanderMethodArgumentResolvers.
Added HandlerMethodArgumentResolver implementations for Pageable and Sort exposing a new default set of properties (page, size, sort) to resolve pagination and sorting information from the request. To mimic the legacy behavior we expose a (deprecated) LEGACY constant in PageableHandlerMethodArgumentResolver. Clients should move to the new properties structure ASAP. Added unit tests to verify old and new defaulting behavior.

Introduced new annotations @SortDefault (with @SortDefaults wrapper annotation) and @PageableDefault (superseding the legacy @PageableDefaults). The new annotations have more speaking attribute names and the HMAR implementations transparently alias the generic value attribute into a more semantic one (size).

The HMAR implementations implement Spring HATEOAS' UriComponentsContributor to be able to turn Pageable / Sort instances back into URIs created through the MethodLinkBuilderFactory API in Spring HATEOAS.

Extracted common API between legacy PageableArgumentResolver and PageableHandlerMethodArgumentResolver into common helper class.
Upgraded to Spring Hateoas 0.5.0.BUILD-SNAPSHOT.
2013-02-19 13:09:40 +01:00
Oliver Gierke
ed32d83ab3 DATACMNS-287 - Added missing package-info.java files. 2013-02-19 12:47:01 +01:00
Oliver Gierke
9fae10750e DATACMNS-286 - Extended Page/Pageable APIs.
Pageable and Page interfaces now expose API to easily access Pageables pointing to the previous and next Page instance if available.
2013-02-19 12:45:11 +01:00
Oliver Gierke
0aef8c60b7 DATACMNS-283 - MappingInstantiationException captures more context now.
If an exception occurs in ReflectionEntityInstantiator we now capture more context about the failed instantiation.
2013-02-15 18:34:56 +01:00
Oliver Gierke
e093aead13 DATACMNS-117 - Added PageableHandlerArgumentResolver.
Added PageableHandlerArgumentResolver to supersede the now deprecated PageableArgumentResolver. The latter still stays available for Spring 3.0.x based deployments. Updated reference documentation to mention the newly introduced type as well as possible configuration options.
2013-02-12 17:35:15 +01:00