Commit Graph

1557 Commits

Author SHA1 Message Date
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
9c8aaac0c4 DATACMNS-1155 - Updated changelog. 2017-10-11 19:01:30 +02:00
Oliver Gierke
bddeba77e7 DATACMNS-1190 - Polishing the polishing.
Slight rewording. Extracted path to Spring Framework JavaDoc into variable.

Original pull request: #253.
2017-10-11 15:42:57 +02:00
Mark Paluch
e1f1e9c2db DATACMNS-1190 - Polishing.
Remove existing section on Null-safety. Augment Null handling section with bits of the previous documentation, explicitly describe annotations expressing null-constraints, include full-qualified imports, mention kotlin-reflect dependency for Kotlin metadata introspection. Align callouts, add links, slightly improve wording, typos. Extend year range in copyright header.

Original pull request: #253.
2017-10-11 15:39:16 +02:00
Oliver Gierke
456a901b4d DATACMNS-1190 - Added section on how to enforce nullability constraints on repositories.
Original pull request: #253.
2017-10-11 15:39:16 +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
Oliver Gierke
5ebcee90c9 DATACMNS-1188 - Polishing.
Fixed indentation in CrudRepository and aligned callouts.
2017-10-05 09:47:10 +02:00
Nicolas Mervaillie
bfaafca3b7 DATACMNS-1187 - Fixed broken links in reference documentation.
Fix link to ExampleMatcher. Removed reference to non-existing section Query by Example Execution.

Original pull request: #252.
2017-10-04 10:33:03 +02:00
Oliver Gierke
0386ec04ca DATACMNS-1188 - Reflect API changes in CrudRepository in reference documentation. 2017-10-04 10:19:00 +02:00
Mark Paluch
78a874cf0c DATACMNS-1156 - After release cleanups. 2017-10-02 11:37:22 +02:00
Mark Paluch
a0f67c1909 DATACMNS-1156 - Prepare next development iteration. 2017-10-02 11:37:21 +02:00
Mark Paluch
dc85837958 DATACMNS-1156 - Release version 2.0 GA (Kay). 2017-10-02 11:10:22 +02:00
Mark Paluch
497edfeefb DATACMNS-1156 - Prepare 2.0 GA (Kay). 2017-10-02 11:09:17 +02:00
Mark Paluch
96d0a12e5a DATACMNS-1156 - Updated changelog. 2017-10-02 11:09:08 +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
Mark Paluch
2220bed116 DATACMNS-1179 - Adapt to changed Spring Framework 5 documentation structure.
Update links in the reference docs to their new locations.
2017-09-27 12:19:47 +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
Mark Paluch
2b4ef1a555 DATACMNS-1175 - Remove argument array caching from EntityInstantiators.
We no longer cache argument arrays in our EntityInstantiators to prevent changes to shared mutable state caused by reentrant calls.

Previously, a re-entrant call requesting an argument array of the same size as a previous call in the call stack reused the same array instance. Changes to this shared mutable state by multiple invocations caused an invalid state rendering wrong parameters for object instantiation. Removing the caching and only reusing an empty array for zero-arg constructors is the only safe approach for now.

Re-instantiation of object allocations results in a higher GC pressure but guarantee side effect-free instantiation and should be on-par with previous versions performance profile.

Original pull request: #247.
2017-09-27 10:55:34 +02:00
Mark Paluch
cc0ab54c38 DATACMNS-1171 - Do not create PersistentEntity for unsupported Kotlin classes.
We now reject unsupported Kotlin classes from the MappingContext by default by not creating persistent entities.

Original pull request: #245.
2017-09-25 12:23:35 +02:00
Mark Paluch
d9d0d594e5 DATACMNS-1171 - Limit Kotlin reflection support to regular classes.
We now only inspect regular Kotlin classes with inspection to adapt Kotlin-specific behavior. Multipart-, synthetic and unknown classes are not supported. In such cases we fall back to the JVM reflection mechanism.

Non-regular classes are typically synthetic stubs, lambdas and SAM conversion which do not represent typical domain objects but rather technical bridge code.

Original pull request: #245.
2017-09-25 12:23:30 +02:00
Oliver Gierke
65e21344ac DATACMNS-1173 - Fixed value lookup of AnnotationRevisionMetadata.
Fixed handling of absent values. Minor refactorings. More unit tests.
2017-09-25 09:56:31 +02:00
Mark Paluch
041c18bef9 DATACMNS-1170 - Fallback to default constructor discovery for Kotlin classes without primary constructor.
We now fall back to default preferred constructor discovery if a Kotlin class has no primary constructor and no preferred constructor is resolved. Previously, primary constructor resolution yielded no result (returned null) which caused the subsequent Java constructor lookup to fail.

Original pull request: #244.
2017-09-22 12:11:04 +02:00
Mark Paluch
93c65c02fe DATACMNS-1159 - Downgrade to CDI 1.0.
We now build against CDI 1.0 again while using CDI 2.0 for testing.
2017-09-22 11:47:11 +02:00
Oliver Gierke
d9860f2d20 DATACMNS-1161 - Polishing.
Typo in JavaDoc.

Original pull request: #243.
2017-09-21 18:14:57 +02:00
Jens Schauder
ea03388a7c DATACMNS-1161 - Renamed PersistentProperty.getPersitentEntityType(…) to ….getPersitentEntityTypes(…).
The new name currently delegates to old version, so classes only implementing the old method still work. Old name is deprecated.

Original pull request: #243.
2017-09-21 17:46:28 +02:00
Oliver Gierke
404610ebb4 DATACMNS-1168 - QuerydslPredicateBuilder now returns empty predicate by default. 2017-09-21 16:23:40 +02:00
Oliver Gierke
7987896098 DATACMNS-1167 - Added explicit automatic module name for JDK 9. 2017-09-21 11:58:18 +02:00
Oliver Gierke
a15c82c414 DATACMNS-1157 - Polishing.
Tiny formatting fixes in the reference documentation.

Original pull request: #241.
2017-09-21 10:24:01 +02:00
Mark Paluch
b992c38256 DATACMNS-1157 - Polishing.
Fix typo in reference to AfterDomainEventPublication.

Original pull request: #241.
2017-09-21 10:23:54 +02:00
Mark Paluch
fcf97e1e71 DATACMNS-1157 - Enforce nullable/non-null API constraints on repository query methods.
We now validate query method invocations to check method parameters whether they accept null values and reject execution if null values are not supported. We derive nullability support from repository interfaces declared using Kotlin and Spring's NonNullApi/Nullable annotations.

We also check whether a query method can return null. If a query method returns null which isn't supposed to do so, then we throw EmptyResultDataAccessException to prevent null return values.

interface UserRepository extends Repository<User, String> {

  List<User> findByLastname(@Nullable String firstname);

  @Nullable
  User findByFirstnameAndLastname(String firstname, String lastname);
}

interface UserRepository : Repository<User, String> {

  fun findByLastname(username: String?): List<User>

  fun findByFirstnameAndLastname(firstname: String, lastname: String): User?
}

Original pull request: #241.
2017-09-21 10:23:47 +02:00
Oliver Gierke
2c20377cfa DATACMNS-1166 - Upgrade to Vavr 0.9.1. 2017-09-21 09:25:11 +02:00
Oliver Gierke
e7ae4a8bb8 DATACMNS-1165 - Added support for Streamable as repository return type.
We now allow users to use our own Streamable interface as query method return types to easily invoke ….stream() on everything that returns an Iterable using non-parallel streaming by default.
2017-09-20 16:31:29 +02:00
Oliver Gierke
1a199847cd DATACMNS-1162 - Improved support for immutable aggregates.
AbstractAggregateRoot is now generified to be able to use its concrete type on methods returning an instance of itself. Added new methods andEvent(…) and andEventsFrom(…) to easily transfer events from another aggregate instance. Added unit tests for fundamental functionality of the base class.
2017-09-20 11:45:37 +02:00