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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Static factory methods on Specifications are now more lenient regarding null values eventually evaluating to null predicates on concatenation attempts.
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.
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.
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.
Specifications.not(…) now also gets applied correctly when used without where(…) wrapper. Polished Specifications class, JavaDoc and added not null assertions.
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.
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.
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
The repositories can now be bootstrapped using @EnableJpaRepositories annotation as follows:
@Configuration
@EnableJpaRepositories
class ApplicationConfig {
// … declare EntityManagerFactory
// … declare PlatformTransactionManager
}
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.
Drop custom method to determine whether a query method returns an entity and rather use the newly introduced method in Spring Data Commons' QueryMethod.
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.