Commit Graph

304 Commits

Author SHA1 Message Date
Oliver Gierke
b3324a0e7d DATAJPA-871 - CrudMethodMetadataPostProcessor now uses the bean ClassLoader.
The thread-local proxy for the CrudMethodMetadata is now created using the bean ClassLoader, which the repository factory gets set from the container.

Renamed the property for the post processor and its lookup method.
2015-11-05 19:01:19 +01:00
Oliver Gierke
a3e73a4c40 DATAJPA-815 - Fixed application of sorting in combination with join aliases.
The application of sort expressions is guarded by the detection of join aliases to potentially prefix the sort expression with the default alias. In case a raw property reference to sort by started with a join alias the property name wasn't prefixed. We now explicitly check for a start with the alias followed by a dot.
2015-10-21 11:24:21 +02:00
Oliver Gierke
7fb58c3c47 DATAJPA-809 - ParameterBinder now uses ParameterAccessor.
We now use a ParameterAccessor to obtain query method parameters in ParameterBinder to benefit from value post-processing (e.g. unwrapping of Optional etc.).

Related tickets: DATACMNS-768.
2015-10-07 19:39:37 +02:00
Oliver Gierke
7fa997085d DATAJPA-585 - Fixed potential NullPointerException in QueryDslJpaRepository.
findAll(Predicate, Pageable) now treats null Pageable instances correctly.
2015-10-06 07:34:12 +02:00
Oliver Gierke
945acce07d DATAJPA-808 - Introduced AttributeConverters for ZoneId for JSR-310 and ThreeTenBP. 2015-10-05 18:39:34 +02:00
Oliver Gierke
fda74889de DATAJPA-798 - Alias detection now also works for JPQL strings containing line breaks.
We tweaked the regular expression to detect query aliases to correctly use the whitespace character class \s instead of a simple space to make sure we don't get fooled by other whitespace characters like tabs and line breaks.
2015-09-14 10:43:26 -04:00
Thomas Darimont
7d77294ff4 DATAJPA-382 - Demonstrate that dynamic SpEL parameters work in update queries.
Added test case to AbstractAuditingViaJavaConfigRepositoryTests that uses the SampleEvaluationContextExtension to demonstrate access of "security" context objects as well as dynamic SpEL Expression binding.

Needed to add FixedDate helper class to ease checks for modification time stamps.

Original pull request: #152.
2015-09-09 13:39:34 +02:00
Oliver Gierke
1e7e5fbb1b DATAJPA-785 - Adapted test cases to build against Hibernate 5 GA.
Added a few flushes and transaction rearrangements for low level integration tests to accommodate changes in flushing behavior in Hibernate 5 GA.
2015-08-28 15:52:49 +02:00
Oliver Gierke
1eaeaa0e9d DATAJPA-775 - Improvements to Spring Data @Version detection.
Moved the detection of an invalidly used @Version to the verification phase of the JpaPersistentEntity so that the MappingContext doesn't even bootstrap if a misconfiguration is detected.

The previous approach would've detected the invalid stage at access time which might actually occur too late.

Original pull request: #153.
2015-08-13 09:49:52 +02:00
Greg Turnquist
c9fee0c4f3 DATAJPA-775 - JpaPersistenPropertyImpl now rejects Spring Data Commons' @Version.
JpaPersistentPropertyImpl now defensively checks whether Spring Data Commons' @Version annotation is used instead of the JPA one and throws an exception if so as the persistence providers can only deal with the latter and optimistic locking won't work correctly otherwise.

Original pull request: #153.
2015-08-13 09:49:49 +02:00
Oliver Gierke
b92b9fb14b DATAJPA-772 - Fixed accidental application of LIKE-expansions for non-String parameters.
ParameterMetadataProvider now applies LIKE-expansions only for String properties.
2015-08-07 16:43:16 +02:00
Oliver Gierke
dbc5a3ffd0 DATAJPA-763 - Polishing.
Reworked integration test to make it work on EclipseLink, too. Simply checking for new no joins doesn't work here as it even adds joins for plain attribute traversals using root.get(…). We're now using Mockito to verify the expected behavior on the interaction level instead of the Root's state.

Removed superfluous finals. Added some Javadoc where necessary.

Original pull request: #151.
2015-07-20 19:00:10 +02:00
Matthias Herrmann
77ce120e46 DATAJPA-763 - Building up joins now considers already registered fetches, too.
QueryUtils.toExpressionRecursively(…) now also checks the provided root for already existing fetches to avoid creating superfluous join.

Original pull request: #151.
2015-07-20 16:50:52 +02:00
Oliver Gierke
0cbfefc722 DATAJPA-758 - Named parameters for derived are only used if they're explicitly named.
If parameter names for derived queries use names that collide with reserved keywords in JPQL (e.g. key) switching on Java 8 parameter name discovery previously caused the query execution to fail.

We now check whether the parameter has been explicitly named (using the @Param annotation) and only use the name if so.
2015-07-15 16:23:08 +02:00
Oliver Gierke
e8e8e1b7e2 DATAJPA-758 - JpaQueryMethod now only checks parameter names if query uses named parameters.
We now only validate parameter names if the declared query actually uses named parameters.

This is mainly needed in context of an (accidentally) mixed use of named parameters with indexed placeholders which can occur if compiling with parameters is activated on Java 8 (i.e. using -parameters) but indexed parameters are used in the query definition.
2015-07-10 18:48:30 +02:00
Oliver Gierke
a58bfea3b6 DATAJPA-703 - Upgraded to Hibernate 5 CR1. 2015-07-07 13:59:33 +02:00
Oliver Gierke
83a3db6089 DATAJPA-757 - Count queries for String-based native queries are now executed as native ones.
AbstractStringBasedJpaQuery now considers the native flag of the underlying JpaQueryMethod when creating count queries. 

Had to widen the return type of   AbstractJpaQuery.createJpaQuery(…) to Query to accommodate the return value  EntityManager.createNativeQuery(…). Tweaked the implementation of PagedExecution to handle non-Long return values potentially converting them to longs to retain API.
2015-07-07 13:49:37 +02:00
Oliver Gierke
5f1ab5661b DATAJPA-669 - Introduced JpaContext to abstract the current JPA setup.
DefaultJpaContext is set up of all EntityManager instances in the current ApplicationContext and exposed for injection. Its interface JpaContext then currently allows looking up EntityManagers by managed domain types.

If multiple EntityManagers of the current ApplicationContext manage the a single domain type the request is rejected.
2015-07-06 15:36:49 +02:00
Oliver Gierke
94cd342038 DATAJPA-736 - Added support for non-ASCII characters in entity names.
We now use an improved regular expression to detect identifier clauses in JPQL queries to be able to derive count queries for queries that use non-ASCII characters in entity names.
2015-06-14 12:09:12 +02:00
Oliver Gierke
67b93c2073 DATAJPA-726 - Fixed alias detection for queries containing joins.
We now not only detect alias in left (outer) joins but basically all of them to find out whether or not to prefix sort expressions with the root alias.
2015-05-22 14:18:43 +02:00
Thomas Darimont
2f5f269932 DATAJPA-712 - Fix binding of SpEL parameters with IN-clause.
We now ensure that all the SpEL parameters are correctly substituted when used together with an IN-clause. Previously we incorrectly used the initial query as the result again which then only substituted the very last parameter correctly.

Original pull request: #148.
2015-05-19 16:40:03 +02:00
Oliver Gierke
f092c4edf8 DATAJPA-716 - Strengthened tests for updatability detection in JpaPersistentProperty.
Added negative check, too, and tweaked implementation to actually correctly detect the updatability.
2015-05-19 13:47:17 +02:00
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