Commit Graph

415 Commits

Author SHA1 Message Date
Oliver Gierke
8599ecf019 DATACMNS-879 - Polishing.
Some cleanups in ExampleMatcherAccessor.
2016-07-14 21:03:10 +02:00
Oliver Gierke
d41a9cb5c5 DATACMNS-879 - ExampleMatcher now allows to define whether all or any match should be used.
Introduced dedicated factory methods for ExampleMatcher so that it exposes whether the predicates built from Example instances have to be fulfilled all or if it's sufficient that any of them matches.
2016-07-14 08:54:56 +02:00
Mark Paluch
20653a7ebc DATACMNS-874 - Fix Scala Option unwrapping.
We now correctly unwrap empty Scala Options so the unwrapping no longer fails.

Original pull request: #165.
2016-06-28 14:31:34 +02:00
Pascal Grün
ce2e788374 DATACMNS-869 - Fix Javadoc for parametric types of Pair.
Original pull request: #164.
2016-06-11 18:21:20 +02:00
John Blum
1d880f2e08 DATACMNS-868 - Assert JDK 6 compatibility in ResultProcessor.
Turned the previously anonymous inner class that applies result processing to a JDK 8 Stream into a dedicated inner class to avoid JDK types being loaded on older JDKs. The previous way was causing issues due to the JVM trying to resolve the Function interface when loading the ResultProcessor class.

Original pull request: #163.
2016-06-09 09:13:16 +02:00
Oliver Gierke
d4c0aa70ba DATACMNS-866 - Improved error message in invalid invocations of BasicPersistentEntity.getPropertyAccessor(…).
We now explicitly report the given object's type and the one expected in case of a mismatch when BasicPersistentEntity.getPropertyAccessor(…) is invoked.
2016-06-08 16:10:25 +02:00
Oliver Gierke
241d18a212 DATACMNS-863 - Fixed parameter type lookup for wrapper types.
When repository parameters use wrapper types (e.g. Optional) the Parameter instance for that parameter now returns the component type.
2016-06-04 14:35:39 +02:00
Oliver Gierke
65bfd5b33a DATACMNS-743 - Optimizations in TypeDiscoverer getProperty(…) in case if invalid property names.
We now also cache a failed property lookup so that we can return null on a subsequent call for the same invalid property name right away and don't have to reattempt the lookup unnecessarily.
2016-06-01 18:38:58 +02:00
Oliver Gierke
e414cd6801 DATACMNS-862 - ReturnedInterface now considers interfaces implemented by the domain type.
We now check whether the interface return type is implemented by the domain type and opt out of all projection efforts if so.
2016-06-01 17:50:08 +02:00
Oliver Gierke
5b5daaf397 DATACMNS-831 - Polishing.
Formatting. Fixed copyright header and author. Added missing assertions in AbstractMappingContext.addPersistentEntity(…).

Original pull request: #157.
2016-05-31 18:52:36 +02:00
Mikael Klamra
046f0408d1 DATACMNS-831 - AbstractMappingContext.addPersistentEntity(…) now acquires necessary read lock.
The lookup for already available PersistentEntity instances now acquires a read lock to shield the execution from partially equipped PersistentEntity instances currently in creation from another thread.

Original pull request: #157.
2016-05-31 18:50:59 +02:00
Oliver Gierke
1bedfe4f4a DATACMNS-856, DATACMNS-685 - Made ToEntityConverter.matches(…) less offensive.
ToEntityConverter.matches(…) now doesn't throw an exception anymore as it might be picked up by classpath scanning an the exception previously thrown causing the entire conversion attempt to abort.

We're now rather inspecting the ToEntityConverter in case the target type is a repository managed one and the ToIdConverter otherwise.
2016-05-31 18:10:39 +02:00
Oliver Gierke
bdc61a044f DATACMNS-859, DATACMNS-860 - Improvements to ResourceProcessor.
ResourceProcessor supports Streams now and adds a map(…) step to apply projections.

Also, the ProjectingConverter falls back to use a default ConversionService instance to make use of the object mapping functionality implemented in ObjectToObjectConverter, i.e. the ability to just map an object returned from the store to a DTO in case that latter exposes a constructor or factory methods taking the source instance as parameter.

Related tickets: DATAJPA-903.
2016-05-25 15:04:29 +02:00
Oliver Gierke
3a36ed55dd DATACMNS-854 - Polishing.
Simplified conditional expressions in DefaultRepositoryInformation. Reordered test method to reflect natural order of adding.

Original pull request: #162.
2016-05-24 19:05:37 +02:00
Terje Strand
e0fc7deb05 DATACMNS-854 - Allow custom implementation of repository methods with generics.
Add additional check for detecting customized method where method contains generics. Overriding methods without generics already works, this patch simply makes the behavior consistent.

Original pull request: #162.
2016-05-24 19:05:31 +02:00
Oliver Gierke
87566df432 DATACMNS-858 - Polishing.
Some JavaDoc and formatting.
2016-05-21 12:02:19 +02:00
Oliver Gierke
c51f55346f DATACMNS-858 - Fixed JavaDoc for CrudMethods.getDeleteMethod().
We're now correctly stating that we're preferring the delete method that takes the entity as argument over the one taking the id to match what's actually implemented.
2016-05-21 12:01:59 +02:00
Oliver Gierke
fa7ab50c5f DATACMNS-855 - Fixed generic type lookup in SyntheticParamterizedType.
The translation of the list of actual type parameters into an array now uses the loop index correctly. Previously, it always used the first type parameter.
2016-05-13 11:32:31 +02:00
Oliver Gierke
9db6278e77 DATACMNS-855 - Prevent memory leak in SyntheticParameterizedType.
Added proper equals(…) and hashCode() methods to SyntheticParameterizedType to make sure instances created for the same type information and type parameters are considered equal.
2016-05-12 16:48:01 +02:00
Oliver Gierke
f29cbf5752 DATACMNS-853 - Polishing.
Simplified test case. Formatting in ClassGeneratingPropertyAccessorFactory.

Related tickets: DATACMNS-809.
Original pull request: #161.
Related pull request: #160.
2016-05-12 15:45:05 +02:00
Mark Paluch
db5259292c DATACMNS-853 - Support interface entity types using generated property accessors.
Property accessors (getter and setter) defined on an interface require a different instruction opcode for invoking methods. We now distinguish whether a property accessor is defined on an interface and use either INVOKEINTERFACE or INVOKEVIRTUAL otherwise.

Related tickets: DATACMNS-809.
Original pull request: #161.
Related pull request: #160.
2016-05-12 15:31:09 +02:00
Oliver Gierke
38a41139fc DATACMNS-809 - Polishing.
Removed DefaultPersistentPropertyAccessorFactory as it only delegates to the class generating one. Tweaked AbstractMappingContext to actually use the latter in the first place. Introduced BeanWrapperPropertyAccessorFactory to implement the default behavior of using a BeanWrapper and initialize BasicPersistentEntity to avoid a null clause in getPersistentPropertyAccessor(…).

Removed getPersistentPropertyAccessorFactory and rather rely on ReflectionTestUtils in tests to avoid additional API being exposed.

Original pull request: #159.
2016-05-03 16:47:54 +02:00
Mark Paluch
defc3c7874 DATACMNS-809 - Refactor BasicPersistentEntity to set PersistentPropertyAccessorFactory.
PersistentPropertyAccessorFactory can be set on a BasicPersistentEntity. This is done by AbstractMappingContext once the entity is verified. This change reduces the count of PersistentPropertyAccessorFactory instances and performs the isSupported check only once, when initializing the entity.

Original pull request: #159.
2016-05-03 16:47:54 +02:00
Oliver Gierke
41fe89743b DATACMNS-809 - Polishing.
Made as many methods in ClassGeneratingPropertyAccessorFactory static as possible. Some code formatting. Some warning suppressions where needed.

Original pull request: #159.
2016-05-03 16:47:54 +02:00
Mark Paluch
899a98c83e DATACMNS-809 - Add Class-generating property accessor factory.
We now support generated PersistentPropertyAccessors when using Java 7 and if property/association name hashCodes are unique within a PersistentEntity.
Generated PersistentPropertyAccessors provide optimized access to properties. They use either MethodHandles or direct property/field access, depending on the visibility/final modifiers of the entity type and its members. A generated PersistentPropertyAccessor is injected into the originating class loader of the entity class to enable optimizations for package-default/protected member access.

Original pull request: #159.
2016-05-03 16:47:53 +02:00
Oliver Gierke
0515b1308c DATACMNS-850 - ReturnedClass now does not consider core Java types DTOs.
We now completely ignore all core Java types (i.e. types with a package name starting with "java.") from being DTOs. This allows query methods to project on date time types, too.
2016-04-28 16:43:06 +02:00
Oliver Gierke
9798411b1b DATACMNS-844 - Removed LenientAssignableTypeFilter from RepositoryConfigurationDelegate.
The type was a workaround until an improvement in Spring Framework [0] was fixed. As we now rely on newer versions of the framework, we can remove that type.

[0] https://jira.spring.io/browse/SPR-12042
2016-04-10 13:54:48 +02:00
Oliver Gierke
a44049fa4e DATACMNS-843 - Raised log level for multi-store detection in RepositoryConfigurationDelegate. 2016-04-10 13:49:16 +02:00
Oliver Gierke
156697b043 DATACMNS-843 - Raised log level for dropped repositories in strict configuration mode to INFO. 2016-04-10 11:26:09 +02:00
Oliver Gierke
e1c69c9a2d DATACMNS-840 - Repository query methods returning enums are not considered projecting now. 2016-04-10 11:24:37 +02:00
Oliver Gierke
f6c876b9bd DATACMNS-842 - Projections on repository methods support Slices now.
ResultProcessor now checks for Slice instead of Page as the projection applying method map(…) is available on Slice as well.
2016-04-09 14:09:40 +02:00
Oliver Gierke
3ff31e5f89 DATACMNS-840 - ReturnedType's need for custom construction no includes availability of input properties.
The indicator of whether custom construction is needed for a class based return type now includes whether input properties are available in the first place.
2016-04-08 18:50:57 +02:00
Oliver Gierke
5cfed9e003 DATACMNS-840 - ReturnedClass now aborts parameter name detection for types with multiple constructors.
In case a DTO type exposes multiple no-argument constructors we now leniently abort the parameter name detection and let downstream users decide what to do in this particular case.

The problematic case can't be outright rejected here already as there's valid scenarios for that, e.g. in JPA the type could be used for multiple query methods, using explict constructor expressions listing arguments explicitly and thereby select one of the multiple constructors.
2016-04-08 10:09:37 +02:00
Oliver Gierke
137d7cc544 DATACMNS-818 - Renamed Tuple to Pair.
Got rid off manual implementation code in favor of Lombok annotations.
2016-03-18 09:54:29 +01:00
Oliver Gierke
26f725be0d DATACMNS-810 - Polishing.
Renamed ExampleSpecification to ExampleMatcher and introduced a matching() factory method, dropping the dedicated override mechanism for types for now. Updated documentation accordingly.

Used Lombok for constructor creation, field defaults, toString() as well as equals(…) and hashCode() implementations.

Tweaked imports in unit tests. Renamed methods to express expected behavior.

Original pull request: #153.
2016-03-17 16:22:55 +01:00
Mark Paluch
b0ce7009e8 DATACMNS-810 - Refactor Query by Example API.
Split Example and ExampleSpec to create reusable components. Refactor builder pattern to a fluent API that creates immutable instances. Split user and framework API, Example and ExampleSpec are user API, created ExampleSpecAccessor for modules to access example spec configuration. Create static methods in GenericPropertyMatchers to ease creation of matchers in a readable style. Convert PropertySpecifier to inner class  and move PropertySpecifiers to ExampleSpec.

Related tickets: DATAJPA-218, DATAMONGO-1245.
Original pull request: #153.
2016-03-17 16:17:39 +01:00
Christoph Strobl
4092f0716f DATACMNS-810 - Add core types for Query by Example support.
Added required types for Query by Example which should be used by the individual store implementations. 

Generally the Example type captures a sample object and allow various settings concerning the mapping into an actual query. So there’s configuration options for handling null values, string matching, property paths to ignore,

Related tickets: DATAJPA-218, DATAMONGO-1245.
Original pull request: #153.
2016-03-17 16:17:39 +01:00
Oliver Gierke
a8db5e3d23 DATACMNS-829 - Fixed handling of Map null values in ProxyProjectionFactory.
We now eagerly return null values in attempts to project Map values.
2016-03-15 15:46:56 +01:00
Oliver Gierke
c57bfec696 DATACMNS-828 - Fixed potential NullPointerException in ResultProcessor.
ResultProcessor.processResult(…) now explicitly handles null values to prevent IllegalArgumentExceptions being provoked in the ProjectionFactory which occurred if null values were handed down to it.
2016-03-15 15:04:28 +01:00
Oliver Gierke
71fdf8646e DATACMNS-826 - Fixed JavaDoc for GeoModule. 2016-03-15 13:20:24 +01:00
Oliver Gierke
f0f9d5bc20 DATACMNS-825 - Polishing.
Tweaked annotation cache usage in BasicPersistentEntity.findAnnotation(…).

Original pull request: #156.
2016-03-15 13:20:20 +01:00
Christoph Strobl
a40e247c25 DATACMNS-825 - Allow usage of composed annotations using @AliasFor.
We now resolve composed annotation values using @AliasFor within AnnotationBasedPersistentProperty and BasicPersistentEntity. Nevertheless it is up to the individual store implementation to make use of this.

Original pull request: #156.
2016-03-13 16:30:03 +00:00
Oliver Gierke
ae96301ab0 DATACMNS-812 - Polishing.
Formatting and extension of copyright years.

Original pull request: #154.
2016-03-07 11:33:57 +01:00
Timothy Cheng
bc421f53c0 DATACMNS-812 - Fixed PageImpl.toString() to improve readability.
Add one to the getNumber() in PageImpl.toString() since it uses 0-based index.

Original pull request: #154.
2016-03-07 11:31:42 +01:00
Oliver Gierke
deb884dfb1 DATACMNS-821 - Improved type prediction for FactoryBean implementations.
Previously, we registered an InstantiationAwareBeanPostProcessor to predict the type to be created by RepositoryFactoryBeanSupport by inspecting a particular property value of the registered BeanDefinition.

This has now been elevated to a more generic mechanism that can get a FactoryBean type configured with a set of properties to inspect for a configured type. That new infrastructure now replaces the explicit configuration for RepositoryFactoryBeanSupport with one that's set up via configuration.
2016-02-26 19:21:01 +01:00
Oliver Gierke
d3e6ad104c DATACMNS-820 - Polishing.
Fixed indentation to use tabs instead of spaces. Tweaked structure of if-clauses in PropertyAccessingMethodInterceptor to reduce nesting. Made helper method static. 

Restructured test cases slightly and used ExpectedException rule to verify exceptions. Moved newly introduced test methods more to the end of the file (new tests last).

Added author and copyright year extensions where necessary.

Original pull request: #155.
2016-02-20 20:33:14 +01:00
Mark Paluch
e868577def DATACMNS-820 - Allow setter invocations in projections backed by beans.
Invocations to setter methods are now passed to the backing bean.

Original pull request: #155.
2016-02-20 20:33:13 +01:00
Oliver Gierke
e0d2907905 DATACMNS-815 - Made static type cache non-static in SimpleTypeInformationMapper.
We now use a non-static cache for TypeInformation instances in SimpleTypeInformationMapper to make sure Spring Boot's development tools can correctly reload classes. Removed the static singleton instance of SimpleTypeInformationMapper in favor instantiating it directly.
2016-02-09 14:22:06 +01:00
Oliver Gierke
85e569b4f6 DATACMNS-804 - ParametersParameterAccessor now correctly iterates over only the bindable values.
Corrected the way the BindableParametersIterator works by limiting the upper bound of the iteration to the number of actually bindable parameters.
2016-01-21 10:19:59 +01:00
Oliver Gierke
b17a797fe6 DATACMNS-802 - PagedResourceAssembler now allows customizing the PagedResource instance.
Introduced a template method to override the creation of a PagedResource to allow subclasses to create a more concrete instance than PagedResource itself.
2016-01-20 14:24:38 +01:00