Commit Graph

752 Commits

Author SHA1 Message Date
Oliver Gierke
24a9493fa6 DATACMNS-1243 - Polishing.
Imports and author tags.

Original pull request: #268.
2018-02-01 10:55:34 +01:00
Jens Schauder
58b0cc9c0a DATACMNS-1243 - Add converters from LocalDateTime to Instant and back.
This allows usage of Instant for AuditAware.

Original pull request: #268.
2018-02-01 10:55:34 +01:00
Mark Paluch
4d9329fab8 DATACMNS-1249 - Fix line endings to LF. 2018-01-24 12:32:29 +01:00
Mark Paluch
7c61bdf2c8 DATACMNS-1245 - Consider Kotlin metadata annotation for Kotlin class kind retrieval.
We now inspect Kotlin's Metadata annotation to determine the kind of a Kotlin class.

Previously we used Kotlins internal API to introspect classes. Because this API is not public and can be changed at any time we rely on Kotlins annotations as they are supposed to not change in near future.

Original pull request: #269.
2018-01-19 13:38:29 +01:00
Oliver Gierke
c777363f3d DATACMNS-1246 - Minor optimization in QueryExecutorMethodInterceptor.
We now prevent the superfluous creation of a MethodParameter and TypeDescriptor instance in repository method execution in case the value to be returned already is an instance of the expected method return type.
2018-01-18 17:22:43 +01:00
Mark Paluch
06116b7726 DATACMNS-1206 - Polishing.
Convert type array to string to construct the exception message. Slight Javadoc tweaks. Reduce method visibility. Simplify hasDefaultGetter check. Remove superfluous throws declaration. Strip trailing whitespaces. Ignore property descriptors without getter (e.g. indexed properties).

Original pull request: #263.
2018-01-12 12:28:38 +01:00
Oliver Gierke
5eb10a0817 DATACMNS-1206 - Polishing.
Moved PropertyDescriptor lookup into dedicated subclass to group functionality around the type and MethodsMetadata instances. Extracted individual stream handling steps into dedicated methods for better understandability.

Moved MethodsMetadataReader into classreading package for symmetry with Spring Framework's metadata arrangement. Removed manually declared getters in DefaultMethodsMetadataReader in favor of Lombok getters. Inlined MethodsMetadataReadingVisitor into DefaultMethodsMetadataReader as it's only used there.

Original pull request: #263.
2018-01-12 11:04:49 +01:00
Mark Paluch
9e013d3c14 DATACMNS-1206 - Add API to read methods in declaration order.
We now provide MethodsMetadataReader to read method metadata from a class file. MethodMetadata is read for all user-declared methods except for constructors (which are technically methods, too).

MethodsMetadataReaderFactory factory = new MethodsMetadataReaderFactory();
MethodsMetadataReader metadataReader = factory.getMetadataReader("com.acme.Foo");
MethodsMetadata metadata = metadataReader.getMethodsMetadata();

This new API is now used by DefaultProjectionInformation to make sure the order of input properties is based on the declaration order in the projection interfaces. Previously that order could not be guaranteed to be stable.

Original pull request: #263.
2018-01-12 11:04:31 +01:00
Oliver Gierke
4a2df6299b DATACMNS-1241 - Improved Lazy.
Expanded generics to make sure we can take Functions and Suppliers of sub- and supertypes properly. Added factory method to create a Lazy from a fixed value. Added method to access Optional result. Added methods to allow chaining Lazy instances via ….or(…). Reduced visibility of ….orElseGet(…) as it basically equates to ….or(…).get(Optional)().

More unit tests.
2018-01-10 12:07:31 +01:00
Oliver Gierke
dcb8166bbc DATACMNS-1235 - Polishing.
Introduced BeanLookup to easily create a Lazy<T>-based lookup of a unique bean by type on a ListableBeanFactory. This is in support of making it easy for downstream Spring Data modules to consume the EntityPathResolver declared in an ApplicationContext using XML configuration.

QuerydslWebConfiguration now uses a plain ObjectProvider to access the bean defined falling back to our default.

Original pull request: #265.
2018-01-10 12:07:31 +01:00
Oliver Gierke
408b9abd88 DATACMNS-1235 - Polishing.
Original pull request: #265.
2018-01-10 12:07:22 +01:00
Jens Schauder
9ae4216650 DATACMNS-1235 - Support for package suffix in SimpleEntityPathResolver.
SimpleEntityPathResolver is now a normal class and takes a package suffix in the constructor.

Original pull request: #265.
2018-01-10 12:07:07 +01:00
Mark Paluch
e30928dcf0 DATACMNS-1236 - Fix inconsistent Pageable nullability Javadoc.
Fix Javadoc to reflect Pageable's non-nullability. Also, remove pageable field in favor of using Chunk's Pageable getter.
2018-01-09 12:46:47 +01:00
Mark Paluch
51e7e1b7f5 DATACMNS-1240 - Update copyright years to 2018.
Also, remove some trailing whitespaces and align outdated license header format.
2018-01-08 16:04:34 +01:00
Oliver Gierke
eb2163a29e DATACMNS-563 - Polishing.
Removed obsolete generics. Rearranged some code for better readability.

Original pull request: #267.
2017-12-30 12:14:27 +01:00
Marcel Overdijk
da163fc9e4 DATACMNS-563 - PagedResourcesAssembler now correctly forwards one-index settings to PageMetadata.
Original pull request: #267.
2017-12-30 12:03:23 +01:00
Oliver Gierke
e7f6c62ca1 DATACMNS-1238 - Optimize setting Environment on ClassPathScanningCandidateComponentProvider.
In CustomRepositoryImplementationDetector, we now immediately hand the Environment to the constructor of ClassPathScanningCandidateComponentProvider instead of setting it afterwards. This prevents a default StandardEnvironment from being created in the previously used constructor.
2017-12-30 11:38:09 +01:00
Oliver Gierke
d978c9e7b5 DATACMNS-1237 - Register additional ProxyingHandlerMethodArgumentResolver as first resolver.
We now deploy a custom BeanPostProcessor to customize RequestMappingHandlerAdapter instances by prepending a ProxyingHandlerMethodArgumentResolver (requiring a @ModelAttribute) to the list of resolved HandlerMethodArgumentResolvers to make sure the settings defined in the annotation are applied but the projecting way of data binding is still used.
2017-12-20 22:24:12 +01:00
Oliver Gierke
34cadd0b9b DATACMNS-1224 - Polishing of nullability annotations.
Refactored code to properly check for null fields in Eclipse. Added warning suppressions where suitable.
2017-11-30 00:29:32 +01:00
Oliver Gierke
3c96e4e079 DATACMNS-1158 - Polishing.
Some code reorganization, polishing of nullable annotations, JavaDoc.

Original pull request: #243.
Related issue: DATAJPA-1173.
2017-11-24 11:05:28 +01:00
Jens Schauder
300f3cfd66 DATACMNS-1158 - ProjectionFactory is now configurable by module implementations.
Introduced RepositoryFactorySupport.getProjectionFactory(…) to create a ProjectionFactory to be used for repository instances created. The default implementation uses the SpelAwareProxyProjectionFactory.

The ProjectionInformation implementation is now a named class so it can be used for more specialized implementations.

Original pull request: #243.
Related issue: DATAJPA-1173.
2017-11-24 11:05:17 +01:00
Oliver Gierke
0237760345 DATACMNS-1215 - Fixed repository lookup for proxy domain classes.
We now consistently use the user class for repository (metadata) lookup in Repositories.
2017-11-17 10:18:36 +01:00
Oliver Gierke
e2bac30be4 DATACMNS-1214 - Fixed AbstractMappingContext.getPersistentEntity(PersistentProperty) to now return null for non-entities.
Previously, a call to AbstractMappingContext.getPersistentEntity(PersistentProperty) would've added potentially leniently added the type of the given PersistentProperty, no matter whether it's actually considered to be an entity in the first place. We now defensively check for whether the given property is to be considered an entity (taking potentially registered converters into account) before the potentially entity-creating by-type lookup.
2017-11-16 16:36:27 +01:00
Oliver Gierke
24c1b823c6 DATACMNS-1210 - Polishing.
More fixes of imports. Removed obsolete generics in constructor expressions. Removed a couple of compiler warnings in test cases. Removed assumption for test case to only run on JDK 9.

Original pull request: #259.
2017-11-14 17:59:43 +01:00
Christoph Strobl
309cdc5e43 DATACMNS-1210 - Fix concurrency issue in BasicPersitentEntity.
Make sure to use concurrent collection implementations for properties holding mutable state. Especially the ones making use of computeIfAbsent(…).

Usage of ConcurrentReferenceHashMap allows us to move on without additional changes as it allows to store null values, whereas ConcurrentHashMap would require us to store explicit NullValue placeholders for such cases, potentially causing trouble in downstream store specific projects.

JMH Benchmarks done with the Spring Data MongoDB mapping layer showed a potential performance loss of up to 5%. However a comparison between ConcurrentReferenceHashMap and ConcurrentHashMap did not show any significant difference in performance.

Original pull request: #259.
2017-11-14 17:59:16 +01:00
Oliver Gierke
d8cea8ba1c DATACMNS-1208 - AbstractMappingContext.hasPersistentEntityFor(…) now properly considers cached absence.
AbstractMappingContext.hasPersistentEntityFor(…) now also properly consideres the empty Optional as non-presence as that is held to allow to distinguish between a type completely unkown to the context, or already known but not considered a persistent entity.

Related pull request: #258.
2017-11-14 10:01:32 +01:00
Oliver Gierke
48db42ced8 DATACMNS-1180 - Polishing.
Avoid premature resolution of type in TypeDiscoverer.createInfo(…) and thereby simplify constructor in ParameterizedTypeInformation.
2017-10-27 10:47:20 +02:00
Oliver Gierke
baee26e5e7 DATACMNS-1180 - Fixed accessor lookup for generic properties.
In AbstractPersistentProperty, we now resolve the potentially generic return and parameter types of getters and setters. To achieve that Property has now been made aware of the actual owning type.
2017-10-27 10:40:38 +02:00
Mark Paluch
a13fc238d3 DATACMNS-1201 - Support generated property accessors for types in default packages.
We now support generated property accessors for types that reside in the default package.

Original pull request: #256.
2017-10-24 22:34:30 +02:00
Oliver Gierke
4bd8a3cfc3 DATACMNS-1199 - Added PropertyPath.nested(…).
This allows to obtain a nested property path based on a currently available one.
2017-10-19 12:40:53 +02:00
Oliver Gierke
b3e1601bc6 DATACMNS-1198 - Added PropertyPath.getLeafType() to expose leaf-property type. 2017-10-19 12:25:00 +02:00
Oliver Gierke
d2008ea3b7 DATACMNS-1200 - Polishing.
Left-over whitepspace.

Original pull request: #255.
2017-10-19 12:11:06 +02:00
Mark Paluch
cf5af6a971 DATACMNS-1200 - Fix entity instantiation of Kotlin types using primitives with default values.
We now determine initial values for primitive parameters in Kotlin constructors that are absent (null) and defaulted. We default all Java primitive types to their initial zero value to prevent possible NullPointerExceptions. Kotlin defaulting uses a bitmask to determine which parameter should be defaulted but still requires the appropriate type.

Previously, null values were attempted to cast/unbox and caused NullPointerException even though they had default values through Kotlin assigned.

Original pull request: #255.
2017-10-19 12:01:34 +02:00
Mark Paluch
506fe37aea DATACMNS-1200 - Polishing.
Throw MappingInstantiationException from KotlinClassGeneratingEntityInstantiator if instantiation fails to align behavior with ClassGeneratingEntityInstantiator. Report Kotlin constructor instead of Java constructor if available.

Original pull request: #255.
2017-10-19 12:01:28 +02:00
Mark Paluch
78bd8fb0f7 DATACMNS-1200 - Guard casts to primitive type in ClassGeneratingEntityInstantiator.
We now insert assertions for primitive types before passing these to the actual constructor to prevent NullPointerExceptions. We also output the index/parameter name if the parameter was null.

Original pull request: #255.
2017-10-19 12:01:06 +02:00
Oliver Gierke
32536067f1 DATACMNS-1197 - Polishing.
Some cleanups in KorlinReflectionUtils. Removed compiler warnings about nullability and raw types.

Original pull request: #254.
2017-10-13 17:32:44 +02:00
Mark Paluch
634d8cbbd6 DATACMNS-1197 - Resolve Kotlin interface properties for nullability inspection.
We now resolve Kotlin interface properties to inspect these for nullability. Kotlin-reflect does not resolve interface property accessors yet so we need to handle this aspect ourselves.

Related ticket: https://youtrack.jetbrains.com/issue/KT-20768.
Original pull request: #254.
2017-10-13 17:32:41 +02:00
Oliver Gierke
8ce79c1810 DATACMNS-1196 - Fixed generics lookup for nested generics in ParameterizedTypeInformation.
We now eagerly resolve a generics declaration chain, which we previously - erroneously - expected GenericTypeResolver to do for us. Simplified TypeVariableTypeInformation implementation. Renamed ParameterizedTypeUnitTests to ParameterizedTypeInformationUnitTests.
2017-10-12 18:18:18 +02:00
Oliver Gierke
370b37fbfd DATACMNS-901 - AbstractMappingContext publishes entity added events outside the write lock.
Previously, the publication of the event that indicated a PersistentEntity having been added to it took place before the write lock over the entities had been released. We now keep the lock smaller and publish the addition event *after* the lock has been released.
2017-10-10 16:10:41 +02:00
stonio
aabd9d9860 DATACMNS-1193 - Fixed typo in JavaDoc and reference documentation of PageableDefaults.
Original pull request: #218.
2017-10-10 11:50:55 +02:00
Oliver Gierke
c9e0803bee DATACMNS-1191 - Avoid unnecessary investigation of converters in QueryExecutionResultHandler.
On query execution conversion, we now check an unwrapped Optional's value for assignability to the target type before looking into advanced conversion options to avoid unnecessary code invocations that would eventually return the same instance anyway.
2017-10-06 12:14:48 +02:00
Mark Paluch
11458c9dcf DATACMNS-1181 - Polishing.
Use Spring Framework's Nullable annotation instead the JSR-305 one.

Original pull request: #251.
2017-10-02 10:41:30 +02:00
Mark Paluch
b18989786f DATACMNS-1181 - Adapt MethodHandle lookup of default methods in package-scoped interfaces to changes in Java 9.
We now attempt MethodHandle lookup with deep reflection capabilities via MethodHandles.privateLookupIn(…) to properly resolve default interface methods on interfaces with package-protected visibility. This API is only available in Java 9 so we need to rely on reflection.

Original pull request: #251.
2017-10-02 10:41:17 +02:00
Mark Paluch
fc02b4fd08 DATACMNS-1184 - Fix Javadoc for non-null parameters in QuerydslPredicateExecutor.
Align Javadoc to reflect the non-null contract for Predicate arguments.

Mention unpaged/unsorted factory methods for Pageable/Sort arguments.

Related ticket: DATACMNS-1114.
2017-10-02 10:04:42 +02:00
Oliver Gierke
8da9679fc1 DATACMNS-1172 - Removed ability to use scanning all packages for repository implementations again.
Kept in a separate commit, so that it's easy to add again by reverting this commit. Removed, as the new behavior is effectively what had been documented as intended behavior all the time.

Original pull request: #248.
2017-09-27 16:09:12 +02:00
Oliver Gierke
da88163141 DATACMNS-1172 - Extracted fragment setup into value object.
We now use FragmentMetadata to control the way fragement interfaces and base packages to scan are calculated. Refactored RepositoryConfiguration.getImplementationBasePackages() to not take a parameter.

Original pull request: #248.
2017-09-27 16:09:11 +02:00
Mark Paluch
3bae636e2f DATACMNS-1172 - Limit repository custom implementation scanning by default to repository interface packages.
Custom repository implementation scan defaults to the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

This default can be changed with @Enable…Repositories annotations that support the limitImplementationBasePackages parameter to scan in repository base packages for custom implementations:

@EnableJpaRepositories(limitImplementationBasePackages = false)
@Configuration
class AppConfiguration {
  // …
}

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.
2017-09-27 16:09:11 +02:00
Jens Schauder
90448bdea6 DATACMNS-1177 - Polishing.
Removed redundant static keywords on inner enums.

Original pull request: #250.
2017-09-27 11:41:09 +02:00
Oliver Gierke
aa7dde94d4 DATACMNS-1177 - Polishing.
Formatting. JavaDoc.

Original pull request: #250.
2017-09-27 11:41:09 +02:00
Jens Schauder
79709629ef DATACMNS-1177 - Parameter.isDynamicProjectionParameter() now uses unwrapped type instead of actual type.
When trying to determine if a parameter is a dynamic projection parameter, i.e. the parameter of type Class that determines the projection to use, now the type parameter of that method parameter gets compared with the unwrapped return type. Therefore this works now not only for Maps and Collections but also for the various wrappers defined in QueryExecutionConverters.

Moved the method for unwrapping the return type from AbstractRepositoryMetadata to QueryExecutionConverters in order to make it available to every class needing it. This also puts it closer to the data it is working on.

Original pull request: #250.
2017-09-27 11:40:55 +02:00