Commit Graph

282 Commits

Author SHA1 Message Date
Oliver Gierke
70ad616c4c DATAJPA-696 - Polishing.
Moved logic to create an ad-hoc entity graph into Jpa21Utils to avoid having to create a PersistenceProvider instance just for the sake of creating such a graph. Moved test code for that into newly introduced Jpa21UtilsUnitTests.

JpaEntityGraph now uses an unmodifiable List instead of an array to prevent having to deal with modifications. Jpa21Utils now uses Collection sorting and reversing to be able to use the for-each loop.

Polished imports, JavaDoc and @since tags where necessary.

Original pull request: #140.
2015-05-15 15:04:32 +02:00
Thomas Darimont
1443b155db DATAJPA-696 - Support ad-hoc entity graph definitions for repository finder methods.
We now support the specification of ad-hoc entity graphs on repository finder methods by allowing to specify the fetch graph paths via the "attributePaths" attribute on the EntityGraph annotation.

Configured EclipseLink tests to use dynamic weaving, required for dynamic entity fetch graphs. Fixed typo in CrudMethodMetadataPopulatingMethodInterceptor.

Original pull request: #140.
2015-05-15 15:04:32 +02:00
Oliver Gierke
ebe0a43692 DATAJPA-703 - Added build profile for Hibernate 5.
Disabled outdated Travis build profiles for Spring 4.0 and 4.1. Upgraded profiles for Hibernate 4.2 and 4.3 to the most recent releases.

Fixed stored procedure integration test to really run on EclipseLink for the EclipseLink specific tests. Added workaround for EclipseLink using invalid syntax (see [0]).

[0] https://bugs.eclipse.org/bugs/show_bug.cgi?id=467072
2015-05-12 14:06:47 +02:00
Oliver Gierke
e18a89651e DATAJPA-716 - JpaPersistentPropertyImpl now considers read-only properties.
We now inspect the updateable attribute of @Column and @OrderColumn to expose its configuration via PersistentProperty.isWritable().
2015-05-06 10:44:36 +02:00
Oliver Gierke
4474ef7f04 DATAJPA-710 - Adapt to changes in Spring Data Commons.
Tweaked method signatures in JpaRepositoryFactory after some signature changes in Spring Data Commons. Use newly introduced getTragetRepositoryViaReflection(…) to obtain the repository instance via the super class.

Added repositoryBaseClass() attribute to @EnableJpaRepositories.

Related tickets: DATACMNS-542.
2015-04-29 12:18:14 +02:00
Oliver Gierke
f46cc8ac0b DATAJPA-702 - Added simplified JpaSort.and(…).
Added new ….and(…) methods to JpaSort to take a Direction and Paths or Attributes to allow more concise definition of additional orders.

Slightly changed the method signature for methods on Path taking a Plural attribute to satisfy the compiler.
2015-04-11 13:54:33 +02:00
Oliver Gierke
1ac1856dcb DATAJPA-698 - Upgraded to EclipseLink 2.6.0.
Slightly refactored general infrastructure integration tests to make sure they're executed during the build. Added neccesary ignores to prevent the test cases from running into spec violations.
2015-04-01 13:10:07 +02:00
Thomas Darimont
d07aeae814 DATAJPA-689 - Allow @EntityGraph on CrudRepository.findOne(…).
We now honor @EntityGraph definitions on CrudRepository.findOne(…) which was previously only the case for methods that created a Query explicitly. 

Extracted tryGetFetchGraphHints(…) method from tryConfigureFetchGraph(…) method in Jpa21Utils to allow EntityGraph hints to be used in SimpleJpaRepository.findOne(…). Construction of query hints from context information in SimpleJpaRepository is now performed via the getQueryHints(…) method. Adjusted QueryDslJpaRepository to use query hints as well.

Added unit and integration tests to verify that @EntityGraph information is propagated to findOne executions.

Original pull request: #137.
2015-03-19 19:26:18 +01:00
Oliver Gierke
febd41b10b DATAJPA-685 - Added configuration option to disable default transactions.
@EnableJpaRepositories now has a enableDefaultTransactions attribute that defaults to true. The XML namespace has an equivalent enable-default-transactions attribute on the <jpa:repositories /> element.

Related tickets: DATACMNS-656.
2015-03-10 19:23:14 +01:00
Oliver Gierke
827053fbad DATAJPA-677 - Polishing.
Some simplifications in the persistence provider specific implementation of the CloseableIterator execution. Adapt to renames in Spring Data Commons. Missing JavaDoc. Additional test case to verify support for executing a stream query.

Original pull request: #136.
2015-03-03 21:19:54 +01:00
Thomas Darimont
5a3d920532 DATAJPA-677 - Add support for Java 8 Stream in repository finder methods.
Added support for Streaming query results in Hibernate, EclipseLink and OpenJPA by falling back to store specific APIs to execute the query.

Original pull request: #136.
2015-03-03 21:06:06 +01:00
Oliver Gierke
386c2a5ecd DATAJPA-681 - Adhoc stored procedures now automatically adapt output parameter binding based on input parameters.
If input parameters are named we now also bind the synthetic output parameter by name for adhoc stored procedures.
2015-02-27 19:13:32 +01:00
Oliver Gierke
d1b21f4239 DATACMNS-649 - Added test case to show implementation class' transaction configuration gets picked up for method overrides as fallback. 2015-02-24 12:06:06 +01:00
Thomas Darimont
7ed684b0ab DATAJPA-679 - Added QueryDslPredicateExecutor.findAll(Predicate, Sort).
We now support findAll on QueryDslJpaRepository that accepts a Querydsl Predicate and a Sort and returns a List<T>.

Original pull request: #135.
2015-02-24 09:40:59 +01:00
Thomas Darimont
a5f20d23ce DATAJPA-652 - Added support for REF_CURSOR output parameters for stored procedures.
We now support detecting output parameters for stored-procedures with ParameterMode.REF_CURSOR. Previously we only considered parameters with OUT or INOUT mode as output parameters.

Added additional test cases for various procedure definition options.
Introduced new Dummy test type to avoid polluting the User test type anymore with  additional procedure definitions. Added test for eclipse link and Openjpa but I had to deactivate them since they currently need to be run with HSQLDB V1 which doesn’t support stored procedures.

Original pull request: #130.
2015-02-04 12:47:11 +01:00
Oliver Gierke
78a727ace1 DATAJPA-664 - JpaPersistentProperty.getActualType() now considers special association type.
JPA mapping allows to define a specialized target entity type for associations e.g., to be able to use interfaces with associations but actually have them backed by a JPA entity type.

JpaPersistentPropertyImpl now favors a type detected within an association property over the one declared at the property for calls to getActualType().
2015-01-28 10:59:17 +01:00
Thomas Darimont
2a05e5e1c9 DATAJPA-665 - Add QueryDslJpaRepository.exists(…) method wich accepts a Querydsl predicate.
Introduced QueryDslJpaRepository.exists(Predicate) method to QueryDslJpaRepository.

Related ticket: DATACMNS-636.
Original pull request: #131.
2015-01-26 11:49:59 +01:00
Oliver Gierke
e8436d5de7 DATAJPA-650, DATAJPA-655 - Moved attribute converters into distinct packages.
Keeping both the ThreeTen and JSR-310 JPA 2.1 attribute converters in a single package will make the use of packages-to-scan with Spring's EntityManagerFactoryBean rather difficult as all converters will end up being picked up by the persistence provider where both of them rely on optional project settings (Java 8 or ThreeTenBp on the classpath).

By moving them into separate packages, the classes can be used to point to packages without interfering with each other.
2015-01-08 10:05:41 +01:00
Oliver Gierke
2cf114b7a2 DATAJPA-655 - Polishing.
Renamed the converters to ThreeTenBackPortJpaConverters to better reflect the project we're integrating with.

Related ticket: DATACMNS-628.
2015-01-05 18:18:56 +01:00
Oliver Gierke
3ca07ab63e DATAJPA-655 - Added AttributeConverters for ThreeTen backport library.
We now ship JPA 2.1 AttributeConverters for the ThreeTen back port library [0] similarly to the one we provide for JSR-310.

[0] http://www.threeten.org/threetenbp
2015-01-04 21:43:12 +01:00
Oliver Gierke
703f5f812c DATAJPA-650 - Added JPA 2.1 attribute converters for JSR-310 types.
We now provide JPA 2.1 AttributeConverter implementations for non-time-zoned JSR-310 date/time types inside Jsr310JpaConverters. We transitively use the Jsr310Converters of Spring Data Commons for the actual conversion.

To activate the converters add the Jsr310JpaConverters class to the mapped types of your JPA provider or point your Spring JPA setup to include org.springframework.data.jpa.domain.support as package to scan for JPA persistent types.

Note that this commit requires DATACMNS-623 to be merged as it adds support for JSR-310 Instants to the general converters.

Related tickets: DATACMNS-623.
2015-01-04 16:51:00 +01:00
Oliver Gierke
6d08654917 DATAJPA-638 - Improve bean definition registration for root configuration element.
We now make sure wo register shared bean definitions only once for all usages of a root configuration element (XML or annotation).

Related ticket: DATACMNS-609.
2014-12-01 10:12:05 +01:00
Thomas Darimont
9b801c7b50 DATAJPA-611 - Allow composite keys to be used in SimpleJpaRepository.findAll(Iterable<ID>).
We now support an Iterable of composite primary keys to be passed to findAll(…). Note that since there is no direct support in JPA to perform this query we have to execute a entityManager.find(…) query for every given id, which could lead to performance problems - use with care!

Original pull request: #127.
2014-11-28 12:38:05 +01:00
Oliver Gierke
6da9d60a76 DATAJPA-635 - Added implementation of QueryDslPredicateExecutor.findAll(OrderSpecifier<?>... orders). 2014-11-28 10:15:40 +01:00
Thomas Darimont
47b4d8a3c3 DATAJPA-523 - Make Specifications implement Serializable.
Specifications now implements Serializable to be able to transfer them across systems boundaries. Introduced special Serializable Specification types for composed and negated Specifications.

Note that currently only Hibernate and EclipseLink expression structures implement Serializable - OpenJPA's don't.

Original pull request: #86.
2014-11-28 09:54:19 +01:00
Thomas Darimont
3590075a46 DATAJPA-606 - Improve handling of empty arrays and collections in query parameters.
Introduced potentiallyConvertEmptyCollection method to PersistenceProvider for provider specific handling of empty collections. Special handling is performed for Hibernate and EclipseLink. Conversion is performed in ParameterMetadata.prepare(…). Renamed ParameterMetadataProvider.accessor to bindableParameterValues.

Original pull request: #123.
2014-11-27 18:08:48 +01:00
Thomas Darimont
36a6f958f2 DATAJPA-629 - Allow SpEL template expressions in combination with parameter expressions in @Query.
Previously SpEL template expressions like #{#entityName} could not be used in conjunction with parameter expressions in @Query because the SpEL template parser tried to evaluate the dynamic parameter expressions as well. We now mask the parameters prior to evaluating the SpEL template expression.

Original pull request: #122.
2014-11-27 18:02:51 +01:00
Oliver Gierke
f8d2b7e4ba DATAJPA-632 - Fix SimpleJpaQueryUnit test after cleanups in Spring Data Commons.
We now use a JpaQueryMethod instance rather than a mock as isPageQuery() cannot be mocked anymore as it has been made final.

Related issue: DATACMNS-601.
2014-11-26 12:56:11 +01:00
Oliver Gierke
aeab939ae2 DATAJPA-631 - ResourceLoader improvements in ClasspathScanningPersistenceUnitPostProcessor.
A custom ResourceLoader configured on ClasspathScanningPersistenceUnitPostProcessor is now propagated to the ClassPathScanningCandidateComponentProvider used for looking up entity classes. We also forward the configured environment so that profile annotations are evaluated as well.

Related issue: DATACMNS-591.
2014-11-26 12:40:13 +01:00
Thomas Darimont
0184c95a4b DATAJPA-628 - Use a shared SpelParser instead of recreating it.
We now use a shared SpelExpressionParser and propagate this through the String-based JpaRepositoryQuery implementations to avoid reinstantiations.

Cleaned up ParameterBinder inheritance hierarchy by merging (and removing) ExpressionAwareParameterBinder into SpelExpressionStringQueryParameterBinder.

Original pull request: #121.
2014-11-24 18:15:18 +01:00
Oliver Gierke
5c906ce73c DATAJPA-622 - Polishing.
Renamed CustomAbstractPersistableIntergrationTests to AbstractPersistableIntergrationTests. Reordered declarations in persistence(2).xml to make sure we retain alphabetic sorting.

Original pull request: #115.
2014-11-24 17:37:23 +01:00
Thomas Darimont
8418263461 DATAJPA-622 - AbstractPersistable.isNew() is now annotated with @Transient.
We now mark AbstractPersistable.isNew() property as @Transient for JPA in order to make sure that no JPA provider complains about a missing setter in case a user derives a domain entity from AbstractPersistable. Without this it isn't possible to bootstrap a PersistenceContext.

Original pull request: #115.
2014-11-24 17:37:15 +01:00
Oliver Gierke
cd6d7b6e5b DATAJPA-630 - Add IdentifierAccessor implementation that avoids proxy resolution for id lookups.
We now customize the IdentifierAccessor returned from JpaPersistentEntity.getIdentifierAccessor(…) to allow the identifier lookup use persistence provider specific means. This is needed to make sure we lookup identifiers for proxies correctly for which a field value lookup would not succeed (as the providers do not pre-populate the identifier field).
2014-11-24 13:32:44 +01:00
Oliver Gierke
e067f01fa4 DATAJPA-623 - Fixed package cycles accidentally introduced.
Moved JpaEntityMetadata and DefaultJpaEntityMetadata to query package to avoid a cyclic dependency to it. Jpa21Utils now also resides in the query package as the util package must not depend on other project packages.

Updated the Sonargraph architecture description by adding new architectural artifacts for mapping, the CDI support and utilities. Defined allowed dependencies more strictly to detect architecture violations more aggressively.
2014-11-10 15:50:54 +01:00
Oliver Gierke
1aac6809ea DATAJPA-605 - JpaPersistentProperty implementation now detects JPA's @Version annotation.
Added override for JpaPersistentPropertyImpl.isVersionProperty() to also consider properties annotated with JPA's @Version annotation as version property.

Related pull request: #108.
2014-11-10 14:37:36 +01:00
Thomas Darimont
fb76c9d422 DATAJPA-477 - Avoid query creation in PagedExecution if count query returns 0.
We now skip the query creation if we detect that the preceding count query returned 0 or no results. Previously we always created a query in every case even if it was not necessary.

Original pull request: #113.
2014-11-10 14:24:56 +01:00
Oliver Gierke
be0fcad483 DATAJPA-619 - JpaPersistentPropertyImpl now considers JPA access definition annotations.
JpaPersistentPropertyImpl now looks up both Spring Data and JPA access type definition annotations from both property and type level. Property-level definitions trump type-level ones, Spring Data ones trump JPA ones if defined on the same level.

In support of DATAREST-269 to be able to work around id access issues when working with proxies created by JPA providers.

Related ticket: DATAREST-269.
2014-10-29 11:24:38 +01:00
Thomas Darimont
c585ed3c3b DATAJPA-617 - Avoid potential transaction rollbacks during named query lookups.
We now use a dedicated EntityManager for the named query lookup in NamedQuery.hasNamedQuery(…). Previously we used the given EntityManager to lookup the named query which will cause the transaction to be rolled back due to the Exception thrown in the case that the named query couldn't be found.

Added fast path to NamedQuery.lookupFrom(…) that now uses NamedQuery.hasNamedQuery(…) to test if a query exists or not. Pulled the check for the presence of a named count query from doCreateCountQuery(…) up to the NamedCountQuery constructor. This makes sure that the check is only performed once.

Original pull request: #110.
2014-10-29 09:56:42 +01:00
Thomas Darimont
bacf6cce26 DATAJPA-612 - Allow @EntityGraph on a method inherited from JpaRepository.
We now respect the @EntityGraph annotations on redeclared CRUD methods. CrudMethodMetadata now looks for @EntityGraph annotations, and - if present - the appropriate entity graph configuration is applied within SimpleJpaRepository.applyRepositoryMethodMetadata(…).

Previously we mistakenly treated the @EntityGraph annotation as a Query annotation which triggered a query resolution process that tried to find a named or create a derived query and failed. Removed @QueryAnnotation from @EntityGraph, since it should only be used to mark store specific @Query annotations.

Renamed Jpa21QueryCustomizer to Jpa21Utils. Moved Jpa21Utils to org.springframework.data.jpa.util to avoid potential dependency cycles.

Added EclipseLink and OpenJPA specific subclasses for the EntityGraphRepositoryMethodsIntegrationTests to make sure the tests are executed for EclipseLink and OpenJPA as well.

Original pull request: #109.
2014-10-22 15:07:27 +02:00
Oliver Gierke
6ea82fa1c5 DATAJPA-608 - JpaPersistentPropertyImpl.isEntity() now uses getActualType(). 2014-09-15 14:11:12 +02:00
Thomas Darimont
ebb2be942a DATAJPA-596 - Allow sorting by Querydsl operator expression.
Added test case for sorting by Querydsl operator expression.

Original pull request: #107.
2014-08-26 14:00:03 +02:00
Mark Paluch
cd34005349 DATAJPA-584 - Add support for custom implementations in CDI.
Adapted to API changes in Spring Data Commons. Added test cases to make sure the lookup of custom repository implementations works.

Original pull request: #105.
2014-08-07 14:04:19 +02:00
Oliver Gierke
dfcaeb6a52 DATAJPA-581, DATAJPA-582 - Fixed isNew(…) detection in JpaMetamodelEntityInformation.
We now generally consider all non-null values of a non-primitive @Version attribute indicating a non-new entity.
2014-08-06 09:01:04 +02:00
Oliver Gierke
60c866442a DATAJPA-362 - Added another test case to make sure invalid like bindings are rejected.
Related ticket: DATAJPA-292.
2014-07-18 11:35:42 +02:00
Oliver Gierke
1998874c47 DATAJPA-576 - Improvements in JpaMappingContext setup in configuration.
Refactored JpaMappingContext to be able to work with multiple instances of Metamodel. This removes the need to wire a dedicated one in JpaMetamodelContextFactoryBean and thus makes it independent of a particular EntityManager(Factory). This significantly eases the implementation of the configuration integration.
2014-07-16 16:26:39 +02:00
Oliver Gierke
3467d9257d DATAJPA-574 - Implementation of QueryDslPredicateExecutor now considers lock mode and query hints.
The Querydsl query creation now also leverages the CrudMethodMetadata instance held in SimpleJpaRepository to apply lock mode settings and query hints to the query to be executed.
2014-07-16 13:51:46 +02:00
Oliver Gierke
2b4dfa2aeb DATAJPA-575 - Adapted to deprecation removals in Spring Data Commons.
Related ticket: DATACMNS-469.
2014-07-16 12:04:34 +02:00
Christoph Strobl
68ed8a9082 DATAJPA-568 - Fix is-new detection for primitive version properties.
Some persistence providers do not bump the version number in an initial call to EntityManager.persist(…). Thus, in case of a primitive version property we cannot distinguish between a new entity and one already persisted. We now fall back to id inspection whenever we find a primitive version property.

Original pull request: #103.
2014-07-10 14:28:00 +02:00
Oliver Gierke
59176d6a0a DATAJPA-564 - Polishing of SpEL integration test cases. 2014-07-10 12:18:26 +02:00
Thomas Darimont
26cda66de8 DATAJPA-564 - Allow SpEL expressions to be the only consumer of query method parameters.
Since eclipselink doesn't reliably report whether a given query contains parameter we try to set query-parameters via brute force in SESQPB.
2014-07-10 11:46:52 +02:00