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.
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.
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.
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.
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.
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.
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.
Renamed CustomAbstractPersistableIntergrationTests to AbstractPersistableIntergrationTests. Reordered declarations in persistence(2).xml to make sure we retain alphabetic sorting.
Original pull request: #115.
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.
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).
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.
Added override for JpaPersistentPropertyImpl.isVersionProperty() to also consider properties annotated with JPA's @Version annotation as version property.
Related pull request: #108.
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.
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.
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.
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.
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.
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.
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.
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.
We now allow the parameters of query methods to also be exclusively consumed by expressions within a given query string. Previously this wasn't possible due to to strict checks for parameter usage in JpaQueryMethod.
Relax check for query param usage in JpaQueryMethod.
Enabled HSQLDB support for oracle syntax to be able to use the ROWNUM() function for pagination.
We now allow the parameters of query methods to also be exclusively consumed by expressions within a given query string. Previously this wasn't possible due to to strict checks for parameter usage in JpaQueryMethod.
Relax check for query param usage in JpaQueryMethod.
We came to the conclusion that allowing SpEL expressions as parameters in derived queries would create incentives for users to mess with the low-level Expressions API in high level user code. Therefore we decided to remove this feature - for now.
We now use the rootObject of the delegates context as the rootObject for the expression evaluation as well as the arguments of the current method call are available via positional indices as well via the special variable called "args".
Added minimalistic Security Context infrastructure that mimics that from Spring Security to ease testing.
Referenced appropriate JIRA issues.
We now treat the result of the SpEL expression evaluation as Object instead of just String in ExpressionAwareParameterBinder. We now prefer index based parameter binding over named parameter binding iff only SpEL expression parameters are present. We now make named parameters available as variables in SpEL expressions.
We now support the dynamic discovery and binding of SpEL Expression parameters in query derivation. Introduced ExpressionAwareParameterBinder for generic SpEL expression evaluation support.
We now support the discovery and dynamic registration of SpEL expression parameters in String based queries. Introduced an ExpressionEvaluationContextProvider that provides access to
a potentially shared SpEL EvaluationContext that is defined in the application context. This allow shared spring beans to be used within query expressions.
The SpEL expressions are evaluated in org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.potentiallyBindSyntheticParameters(T) by using a hierarchal EvaluationContext with the RootObject set to the current method arguments.
We enhanced the parsing of ParameterBindings in ParameterBindingParser to support "synthetic" Parameters like SpEL expressions that should be evaluated at query time.
This feature works with Hibernate, EclipseLink as well as OpenJPA.
We currently support those variants:
Indexed parameter:
@Query("select c from Customer c where c.firstname = ?1 and c.attribute1 like ?#{[0] + ' ' + [1]})
To determine the index for the expression parameter we determine the max parameter index present and use that as an offset to generate appropriate parameter indices.
Named parameter:
@Query("select c from Customer c where c.firstname = :firstname and c.attribute1 like :#{[0] + ' ' + [1]})
whereby we generate a name like __$synthetic$__0 for SpEL parameter expression.
The custom handling for Blobs applies to strict conversion as it uses the simple method return type to decide whether to trigger a conversion. It now rather uses the returned domain type which automatically unwraps wrapper types like Guava's Optional.
Applied some polishing to the ConversionService setup in JpaQueryExecution to make more obvious that it's only mean to execute very specific conversions.
Added Guava as test dependency and explicit dependency for the Mysema APT plugin as the test scope only would make it invisible for the plugin.
JPA requires mapping file locations to be classpath relative. Previously we handed the full path to the file (including protocol and JAR path) to the provider, which they happened to understand by accident. To be more spec compliant, we now massage the detected URIs into the expected format.
Original pull request: #81.
Previously, we only checked the version attribute's value against null, which effectively invalidly reported a new entity being non-new in case it used primitive types for the version attribute (as it has a default value then).
We now explicitly check for primitive version property types and consider default values to indicate new state.
We now throw a dedicated InvalidJpaQueryMethodException with a more concrete exception message if we encounter a query method that is annotated with @Query(value = "…", native = true) and erroneously uses a Pageable or Sort parameter. Previously we only threw a IllegalStateException which was then recovered by the CreateIfNotFoundQueryLookupStrategy which tried to do query method derivation as a last resort. This resulted in a cryptic exception message to be thrown that indicates the derivation failure rather than the original error.
Original pull request: #97.
We now support to restrict the results of a query method via the "Top" or "First" keyword within the method name. We adjust the firstResult offset of the query in case we detect a tighter bound on the result size limit form the derived query method that is smaller than the page size of the given Pageable.
Added test cases for Paged and Sliced query executions.
Original pull request: #96.
We now delegate the exists(…) check to findOne(…) in SimpleJpaRepository for entities that have a complex composite id via @IdClass. Previously we tried to generate a string based count query in that case, which didn't work since the parameter types for the IdClass attributes didn't match the values returned by entityInformation.getCompositeIdAttributeValue(…).
Polished JavaDoc in JpaEntityInformation.
Original pull request: #95.
Special characters like french accents (e.g., abonnés) were not allowed anymore (was in SD JPA 1.2) in named parameter bindings. Adjusted regex in StringQuery to cover a broader list of characters.
Original pull request: #93.
We now support to specify just the projection part for the count query generation via the "countProjection" property of the @Query annotation.
This avoids having to repetitively specify parts of the original query.
Original pull request: #84.
Some JpaProviders (read: Hibernate in combination with Hibernate Envers) sometimes return null values from ManagedType.getJavaType() for embedded types values.
We now explicitly check for null values before adding the type to the initial entity set processed by the mapping context.
Related pull request: #89.
The main problem was a bug in querydsl 3.3.2 that has been resolved resolved in querydsl 3.3.3 to which we just updated in in spring-data-build/#70.
Cleaner usage of querydsl API and less brittle casting. Added test case for sorting by nested association property that is wrapped in a function, e.g. lower(…).
Original pull request: #87.