Commit Graph

146 Commits

Author SHA1 Message Date
Thomas Darimont
5e5f494ac5 DATAJPA-377 - Remove "order by"-part from generated count query.
Adjusted createCountQueryFor(…) in QueryUtils to leave out the order by part in the generated query. This avoids problems with databases that require columns specified in the order by clause to be in the select / group by list for count queries (e.g. H2). In addition to that this should give us a little performance boost if the database did not already optimize the query execution.

Original pull request: #29.
2013-07-25 21:31:30 +02:00
Oliver Gierke
153999d141 DATAJPA-376 - PersistentProperty now considers JPA @Transient.
JpaPersistentPropertyImpl is now considered persistent if it carries a @javax.persistence.Transient annotation. This should allow persistence providers to safely generate additional fields and not cause trouble in the mapping framework this way.
2013-07-25 10:34:21 +02:00
Oliver Gierke
295424feb2 DATAJPA-373 - Fixed potential NullPointerException in StringQuery. 2013-07-24 09:56:22 +02:00
Thomas Darimont
528363e125 DATAJPA-170 - Add support for SpEL in query expressions.
Introduced ExpressionBasedStringQuery to support the SpEL expression template rendering. This allows manually defined queries in either @Query or Spring Data named queries to use SpEL and reference the #entityName. Changed SimpleJpaQuery to use ExpressionBasedStringQuery by default. Added test case for repositories with SpEL expression based query methods.

Original pull request: #25.
2013-07-17 10:38:13 +02:00
Thomas Darimont
f25032abfa DATAJPA-353 - Fixed mapping file locations detected by CPSPUPP to conform to the JPA spec.
Adjusted scanForMappingFileLocations(…) in ClasspathScanningPersistenceUnitPostProcessor to resolve the paths to class-path loadable paths. Updated test cases accordingly. Added test case and required resources to verify that mapping files with recursive wildcard pattern can be found from multiple locations in class path.

Original pull request: #24.
2013-07-16 17:33:11 +02:00
Oliver Gierke
4ff0671105 DATAJPA-148 - Remove qualification of sort reference for functions.
When applying Sort instances we now check for the presence of a ( which indicates a function to be executed.
2013-06-27 22:19:01 +02:00
Oliver Gierke
4dffef0943 DATAJPA-348 - Extending workaround for HHH-6951.
We're now using AnnotationUtils.findAnnotation(…) in case of Hibernate to improve workaround for HHH-6951. Added id type caching as the annotation lookup is potentially expensive.

Added integration tests for Hibernate and EclipseLink.
2013-06-20 14:14:06 +02:00
Oliver Gierke
ba74ee10ba DATAJPA-359 - Correctly apply lock config for findOne(…).
SImpleJpaRepository.findOne(…) now applies the lock configuration potentially set on a redeclared method of the repository interface.
2013-06-19 09:35:18 +02:00
Oliver Gierke
62f2231ae2 DATAJPA-352 - Fixed too aggressive validation of count queries.
Count queries are now only validated if the query method is a paging one actually. Improved the exception text in case of a validation error to indicate which method caused it.
2013-06-10 12:04:08 +02:00
Oliver Gierke
29dc2cb8a0 DATAJPA-350 - Improve EntityManager usage for query validation.
SimpleJpaQuery now uses an explicitly created EntityManager instance to verify the manually defined query be able to close the instance explicitly. This will improve GCing the instance.
2013-06-03 13:40:47 +02:00
Oliver Gierke
820655a7c4 DATAJPA-345 - Allow @Lock and @QueryHints to be used as meta-annotations.
@Lock and @QueryHints can now be used as meta annotations to create custom annotations to e.g. reuse a dedicated set of query hints.
2013-05-16 13:24:21 +02:00
Oliver Gierke
f5f4b6b7ad DATAJPA-343 - Fixed count query projection for queries with subselects.
Switched from an accidentally greedy quantifier for the query variable pickup with a possessive one.
2013-05-08 09:51:42 +02:00
Oliver Gierke
d655862251 DATAJPA-342 - Corrected generated count projection from string queries.
The variable put into the count(…) clause of the generated query is now the original value except we find a DTO project or a count projection in the first place.
2013-05-07 14:01:25 +02:00
Oliver Gierke
31006e1866 DATAJPA-341 - Fixed regression introduced in advanced LIKE binding.
We now don't throw an exception anymore in case a normal LIKE binding is used in manually defined queries.
2013-05-04 11:46:18 +02:00
Oliver Gierke
fc4f0c3410 DATAJPA-323 - Added integration tests for JavaConfig and Repositories. 2013-04-26 10:27:33 +02:00
Oliver Gierke
f697b2e102 DATAJPA-296 - Fixed ignore case handling for Querydsl integration.
When using QuerydslPredicateExecutor the ignore case flag defined on the given Order inside a Pageable is considered correctly.
2013-04-25 10:54:26 +02:00
Oliver Gierke
ace028fa2b DATAJPA-330 - Improve setup of persistence exception translation.
Removed the declaration of a global PersistenceExceptionTranslationPostProcessor as the factory already applies one at the bean level selectively. Added integration tests to make sure the translation gets applied and plain @Repository classes not affected at all.
2013-04-24 11:07:58 +02:00
Oliver Gierke
edddb6dfb5 DATAJPA-332 - Optimization for SimpleJpaRepository.findAll(…) taking Iterable.
We now shortcut the execution of SimpleJpaRepository.findAll(Iterable<Integer> ids) to return an empty collection in case no ids or null are given. Previously building a query with an IN clause failed with an empty parameter list given.
2013-04-19 10:51:04 +02:00
Oliver Gierke
4c65ad1df6 DATAJPA-296 - Fixed application of ignore case flag on string queries.
The ignore-case flag held in a Sort.Order is now also applied when manually defining queries.
2013-04-18 11:20:14 +02:00
Oliver Gierke
0bf2cb391e DATAJPA-231 - Added support for derived countBy queries.
PartTreeJpaQuery evaluates the newly introduced PartTree.isCountProjection() to rather trigger a derived count query instead of the actual query. Extended Query execution to potentially massage the returned value into the return type of the query method to allow long and int as return types for count queries.
2013-03-26 15:21:26 +01:00
Oliver Gierke
d364b441b4 DATAJPA-319 - Use default CDI repository scope (application).
Don't inherit the scope of the repository from the EntityManager but let it be the default (application scope singleton).
2013-03-25 17:53:52 +01:00
Oliver Gierke
f6863e6972 DATAJPA-119 - JpaMetamodelEntityInformation now considers @Version.
If a JPA entity class has an @Version attribute we now consider this to determine whether it is new or not. So even if an id is set we'll consider it new as long as the version attribute is null.
2013-03-25 17:53:52 +01:00
Oliver Gierke
9dcf919207 DATAJPA-303 - Added integration test to show auditing on update working. 2013-03-25 17:53:52 +01:00
Oliver Gierke
08831c1f60 DATAJPA-317 - Added @NoRepositoryBean to JpaRepsitory interface.
This prevents the repository from being considered a repository a Spring bean instance has to be created for in case it is accidentally picked up during component scanning.
2013-03-25 17:53:30 +01:00
Oliver Gierke
285a994e95 DATAJPA-292 - Manually defined queries can contain like expressions now.
This commit introduces support for JPQL inline like expressions such as "… like ?1%". The implementation will detect those expressions and turn the query back into a valid JPQL one. On query execution the parameters will be bound according to the like expression defined in the query.
2013-03-13 17:16:53 +01:00
Oliver Gierke
c2aa1215f8 DATAJPA-308 - Improved test case to satisfy Java 6 compiler.
Added explicit type hints to matchers as the code won't compile under JDK 6 otherwise.
2013-03-08 11:54:03 +01:00
Oliver Gierke
8dec595a19 DATAJPA-308 - Improve registration of PersistenceAnnotationBeanPostProcessor. 2013-03-07 12:59:06 +01:00
Kevin Raymond
60923c8651 DATAJPA-296 - Added support for case insensitive sorting.
Modified QueryUtils.toJpaOrder(…) to apply lower criteria if ignore case on Order is set to true and the property being sorted is of type String. Upgraded to Spring Data Commons 1.6.0.BUILD-SNAPSHOT along the way.
2013-02-27 18:47:43 +01:00
Oliver Gierke
22e6ceee53 DATAJPA-300 - Specifications are now more lenient against null values.
Static factory methods on Specifications are now more lenient regarding null values eventually evaluating to null predicates on concatenation attempts.
2013-02-25 16:06:01 +01:00
Thomas Darimont
562dc19b8c DATAJPA-266 - Fixed SimpleJpaRepository.exists(…) for composite ids.
We now build a correct count query for entities that use a compound key mapped using @IdClass. Added integration tests for EclipseLink and OpenJPA to run the basic tests of SimpleJpaRepository against different persistence providers. Ignored failing test against OpenJPA.
2013-01-28 10:58:33 +01:00
Oliver Gierke
943be87908 DATAJPA-288 - Separate test execution for different persistence providers.
Re-enabled more integration tests integration tests.
2013-01-25 18:51:20 +01:00
Oliver Gierke
a74fadd234 DATAJPA-287 - Count query execution now considers distinct flag of query.
If the implementation of a Specification sets the distinct flag, we now create a count query that is honoring the distinct flag as well.
2013-01-25 18:50:45 +01:00
Oliver Gierke
28a565faec DATAJPA-286 - Added test infrastructure for plain JPA tests.
Added integration tests in org.springframework.data.jpa.infrastructure that will not be included in the normal test execution as they are purely means to quickly identify potential differences in persistence provider implementations.
2013-01-17 16:08:00 +01:00
Oliver Gierke
bc6e2a7bc9 DATAJPA-277 - Specification execution with sorting now uses left joins where necessary.
When applying sorting options to a Specification based query we have to make sure to apply left joins where necessary as we otherwise exclude results with null associations. Applying the sort options does an enhanced inspection of the target path and declares a left join instead of a get if the path logically points to an entity. The Metamodel API is not without caveats here, see http://bit.ly/10geC02.
2013-01-17 15:34:10 +01:00
Oliver Gierke
02239859bb DATAJPA-284 - Added @OneToOne as annotation to be considered an association. 2013-01-16 17:48:56 +01:00
Oliver Gierke
258af43397 DATAJPA-274 - Introduce JPA Metamodel based MappingContext implementation.
Implemented rudimentary MappingContext to expose a JpaPersistentEntity through RepositoryFactoryInformation.
2012-11-28 18:15:49 +01:00
Oliver Gierke
69bcc3d887 DATAJPA-272 - Polished logging setup to reduce noise in test cases. 2012-11-27 16:14:53 +01:00
Oliver Gierke
fc818b7087 DATAJPA-116 - Improved implementation to support annotation-based auditing.
Re-engineered our auditing setup to leverage the APIs introduced from DATACMNS-137.
2012-11-27 15:26:22 +01:00
Oliver Gierke
688f62516b DATAJPA-268 - LockModePopulatingMethodInterceptor cleans up resources correctly.
LockModePopulatingMethodInterceptor now safely unbinds the LockModeMetadata after the target method invocation completes.
2012-11-06 14:30:16 +01:00
Oliver Gierke
918099e395 DATAJPA-253 - Fixed application of Specifications.not(…).
Specifications.not(…) now also gets applied correctly when used without where(…) wrapper. Polished Specifications class, JavaDoc and added not null assertions.
2012-08-30 11:36:09 +02:00
Oliver Gierke
a9cfe73511 DATAJPA-252 - Applying sort to manually defined queries considers joins.
If a manually defined query uses outer joins, prefixing the sort criteria handed to the execution of the method causes an additional join being added as the JPA considers path expressions to be inner joins always (see Sect. 4.4.4, JPA 2.0 spec).

We now parse the outer join aliases potentially used in a manually defined JPQL query and do not prefix the query with the root entity's alias.
2012-08-29 17:16:33 +02:00
Oliver Gierke
e59b8b3194 DATAJPA-243 - QueryDslJpaRepository applies sort given through Pageable correctly.
During the refactoring of the Querydsl interaction a regression of not applying a Sort wrapped in a Pageable was introduced in QueryDsl utility class.
2012-08-13 10:28:12 +02:00
Oliver Gierke
372ac45922 DATAJPA-232 - Fixed parameter binding in SimpleJpaRepository.findAll(Iterable<ID> ids).
We bound the given Iterable<ID> using List as parameter type which gets rejected if you hand in something that's not a List actually (e.g. HashSet). Changed parameter binding to hand in Iterable now.
2012-07-19 09:58:39 +02:00
Oliver Gierke
42718c57fe Check OpenJpa query validation. 2012-07-18 11:35:04 +02:00
Oliver Gierke
9734010d8e DATAJPA-226 - Working around ambiguities in the JPA spec.
We now expect a much broader range of exceptions possibly popping up from EntityManager.createQuery(…). It turns out the spec is not very strict about what must be returned from the call in case the provided query String is invalid. E.g. Hibernate seems to throw an IllegalStateException in case the query seems generally acceptable but has a typo in some keyword.

We now catch RuntimeException invoking the call and simply rethrow the original exception if it is an IllegalArgumentException indeed but wrap any other into an IAE.

See http://java.net/projects/jpa-spec/lists/jsr338-experts/archive/2012-07/message/17
2012-07-17 11:41:26 +02:00
Oliver Gierke
2087ce29d2 DATAJPA-69 - Added JavaConfig support for repositories.
The repositories can now be bootstrapped using @EnableJpaRepositories annotation as follows:

@Configuration
@EnableJpaRepositories
class ApplicationConfig {
  
  // … declare EntityManagerFactory
  // … declare PlatformTransactionManager
}
2012-07-16 20:25:49 +02:00
Oliver Gierke
de16544194 DATAJPA-226 - Test case failing to reproduce the issue. 2012-07-16 17:19:06 +02:00
Oliver Gierke
4c1a1450b9 DATAJPA-176 - Introduce Querydsl abstraction.
Introduced Querydsl helper class to allow using more functionality from QuerydslJpaRepository as well as QuerydslRepositorySupport. Moved applyPagination(…) and applySorting(…) methods into that helper class. Removed QuerydslUtils and moved functionality into Querydsl helper.

This change breaks exposed API in Querydsl repo and repo support classes.
2012-06-04 16:33:58 +02:00
Oliver Gierke
fd930e3fde DATACMNS-171 - Let JpaQueryMethod new method of QueryMethod.
Drop custom method to determine whether a query method returns an entity and rather use the newly introduced method in Spring Data Commons' QueryMethod.
2012-05-16 14:36:06 +02:00
Oliver Gierke
72da417171 Improve project setup.
Reactivated test cases that were not executed because they were named *Test, not *Tests. Upgraded to Maven Surefire Plugin 2.12 and activated parallel test execution per method. Upgraded Maven Compiler Plugin to 2.4.
2012-05-15 17:58:25 +02:00