Commit Graph

157 Commits

Author SHA1 Message Date
Oliver Gierke
6fec65b504 DATAJPA-97 - Added test to verify hints get applied to all queries correctly.
The actual fix for this ticket has been introduced during the refactoring for DATAJPA-86 (04349d25dc) thus it's already fixed in 1.1.0.M1. Added a test case to verify the behavior.
2011-09-06 13:19:59 +02:00
Oliver Gierke
9bf6703c63 DATADOC-99 - ParameterExpressionProvider now uses parameter type instead of handed in type if assignable.
JpaQueryCreator hands Comparable into ParameterExpressionProvider to create ParameterExpression instances for Comparables. The ParameterExpressionProvider in turn now inspects the actual Parameter type and hand this one into the builder in case it's assignable (read: more concrete) to the given type requested.
2011-09-06 11:49:07 +02:00
Oliver Gierke
ca52ec29be DATAJPA-81 - SimpleJpaRepository.exists(…) now projects to the id to prevent the entire object being read and mapped. 2011-09-05 08:31:32 +02:00
Oliver Gierke
04349d25dc DATAJPA-86 - Pagination over queries using group-by works correctly.
Added handling of count methods for queries using group by. In case the count query returns multiple results we use the number of results instead of failing. If the result contains one result we use this one.

Moved hint handling to AbstractJpaQuery.
2011-09-04 16:56:50 +02:00
Oliver Gierke
7516816adb DATADOC-93 - Don't catch IllegalArgumentExceptions raised by missing domain class in JPA Metamodel.
We now don't catch an IllegalArgumentException being thrown in case a domain class is not found in the metamodel. If it occurs there's nothing we can do about it as we can't come up with an EntityInformation instance then and the persistence provider couldn't handle it anyway.
2011-09-04 14:25:27 +02:00
Oliver Gierke
b291a5f5f9 DATAJPA-98 - Formatted sources with Spring Data Eclipse formatting settings. 2011-09-02 18:11:10 +02:00
Phillip Webb
27ad91fbbc DATAJPA-92 - JpaQueryCreator now inspects enum to decide how to handle ignore case scenarios. 2011-08-29 18:06:30 +02:00
Phillip Webb
aa6a7c1983 DATAJPA-94 - Repository queries consider Sort instance in a Pageable again. 2011-08-29 11:31:47 +02:00
Phil Webb
5b9e959b3e DATAJPA-92 - Added support for IgnoreCase keyword.
The query creation subsystem now supports using IgnoreCase when referencing String parameters, e.g.:

  findByUsernameIgnoreCase(String username);

Both 'IgnoreCase' and 'IgnoringCase' are supported. If you'd like to entirely ignore cases for all String property references add 'AllIgnoreCase' or 'AllIgnoringCase' to the query method.
2011-08-25 12:52:14 +02:00
Oliver Gierke
0144be5b16 DATADOC-90 - Refactored PartTreeJpaQuery to create new JpaQueryCreator on every query recreation.
JpaQueryCreator is stateful as we create a list of ParameterExpressions and iterate over them. So we have to re-instantiate the JpaQueryCreator to not create an exception on the second attempt.
2011-08-21 14:33:55 +02:00
Oliver Gierke
160b738a4d DATACMNS-62 - Adapt changes in Spring Data Commons. 2011-08-21 14:33:00 +02:00
Oliver Gierke
00ece2c25e Polished codebase and added architecture management.
Added Sonargraph architecture description. Removed cyclic package dependency. Introduced JpaEntityInformationSupport to contain common getEntityName() method and serving as factory for JpaEntityInformation instances.
2011-07-21 12:20:18 +02:00
Oliver Gierke
d0b7901ce8 DATAJPA-78 - Upgrade to Querydsl 2.2.0.
Upgraded to Querydsl 2.2.0. Added configuration to generate query classes for AbstractPersistable and AbstractAuditable. Package those query classes into the source JAR and compile it into the binary as well. Upgraded Mysema APT plugin to 1.0.2.
2011-07-19 17:25:47 +02:00
Oliver Gierke
537ac8c23c DATAJPA-77 - Count queries for manually defined queries don't get pagination applied anymore. 2011-07-19 09:22:02 +02:00
Oliver Gierke
5d3602d53f DATACMNS-49 - Added integration for Spring Data named queries.
We now support extracting query definitions into a properties file which can be configured on the JpaRepositoryFactoryBean. The namespace will look for classpath*:META-INF/jpa-named-queries.properties by default.
2011-06-23 19:47:59 +02:00
Oliver Gierke
405fccb04f DATAJPA-64 - Refactored query execution to use ParameterExpression.
The JpaQueryCreator now creates a CriteriaQuery using ParameterExpressions that have to be bound later on. Refactored the RepositoryQuery implementation hierarchy and JpaQueryExecution as binding has to be done by the query classes now. This required the introduction of a special CriteraQueryParameterBinder as well. It uses the ParameterExpressions of the CriteriaQuery to bind the actual query values later on.

We have to convert arrays passed into query method into collections as none of the major persistence providers support binding arrays to IN parameters currently.
2011-06-21 20:49:54 +02:00
Oliver Gierke
53c3cf9230 DATAJPA-38 - Introduced MergingPersistenceUnitManager. 2011-06-13 20:28:50 -07:00
Oliver Gierke
ea0ff71499 Adapted package refactorings in Spring Data Commons.
Resolved package dependencies as well.
2011-06-13 20:28:23 -07:00
Oliver Gierke
b8ad5e8b81 DATAJPA-68 - Refactored AuditingEntityListener.
Separated touch(…) methods for updating and creation as some persistence providers might hand in entities with IDs already assigned into a @PrePersist method and thus the isNew() check will fail.
2011-06-13 16:24:10 -07:00
Oliver Gierke
356ce6330c Moved QueryDslPredicateExecutor into Spring Data Commons. 2011-05-23 12:23:52 +02:00
Oliver Gierke
75281a99d4 DATACMNS-29 - Adapted changes in Spring Data Commons. 2011-05-12 14:01:56 +02:00
Oliver Gierke
ad40b37f40 DATACMNS-35 - Added implementation and test for newly introduced Repository.delete(ID id) method. 2011-05-11 18:39:27 +02:00
Oliver Gierke
30bb367e96 DATAJPA-59, DATAJPA-60 - Improved handling of PersistenceProviders not capable of extracting queries for paging query methods.
Removed check for that capability (QueryExtractor.canExtractQuery()) from JpaQueryMethod and defer it into NamedQuery as we can handle derived queries and queries annotated with @Query regardless of that capability.

Made exception message a bit more verbose to give hints what to do if the exception occurs.
2011-05-11 13:33:35 +02:00
Oliver Gierke
536f8ccd91 DATAJPA-58 - JpaPersistableEntityInformation now uses Persistable.isNew(…).
Added unit tests to verify behavior and updated changelog accordingly.
2011-05-10 12:20:29 +02:00
Oliver Gierke
33a3c8f5ae DATACMNS-33 - Adapted API changes for Repository.count().
Also changed return types for count() methods on JpaSpecificationExecutore and QueryDslPredicateExecutor.
2011-04-21 10:02:10 +02:00
Oliver Gierke
97859f5dee DATACMNS-32 - Removed Querydsl support classes and use the ones from Spring Data Commons Core. 2011-04-20 20:32:21 +02:00
Oliver Gierke
c2b7047c71 DATAJPA-44 - Adapted changes in Spring Data Commons Core.
Added unit tests to ensure correct named query name.
2011-04-05 11:17:05 +02:00
Oliver Gierke
2959881df5 DATACMNS-24 - Adapted refactorings in Spring Data Commons Core. 2011-04-05 08:04:44 +02:00
Oliver Gierke
a63157237b DATAJPA-8 - Introduced support for QueryDsl specifications
Extracted methods taking a Specification from JpaRepository into JpaSpecificationExecutor. Introduced QueryDslPredicateExecutor that takes QueryDsl Predicate objects to execute them. Introduced QueryDsl specific subclass to execute Predicate instances. Extended JpaRepositoryFactory to rather use the QueryDsl specific implementation if the actual user repository implements QueryDslPredicateExecutor. Added test case to ensure detection of query class. Added QueryDslRepositorySupport to ease implementation of repositories. Added constructor to QueryDslJpaRepository to take an EntityPathResolver to allow plugging in a different implementation. Extracted actual EntityPath resolution tests into unit test for SimpleEntityPathResolver. Check for QueryDsl classpath presence to prevent ClassNotFoundExceptions.
2011-03-15 19:41:27 +01:00
Oliver Gierke
b17f0bf363 DATACMNS-20 - Adapted refactoring of findById(…) to findOne(…). 2011-03-11 18:18:38 +01:00
Oliver Gierke
3128fe2e14 DATAJPA-19 - Adapted generics changes. 2011-03-11 16:24:28 +01:00
Oliver Gierke
bd949cf823 Adapted refactorings in Spring Data Commons. 2011-03-04 09:55:03 +01:00
Oliver Gierke
8e29899eff Added integration test for dynamic sorting. 2011-03-01 20:44:02 +01:00
Oliver Gierke
4be2ac9f5a Reactivate EclipseLink integration test. 2011-02-27 19:15:53 +01:00
Oliver Gierke
99a05d5bb0 DATAJPA-32 - Adopted changes for DATACMNS-17. 2011-02-25 13:55:35 +01:00
Oliver Gierke
44979ac246 DATAJPA-30 - Added support for 'NotIn' keyword. 2011-02-23 10:32:28 +01:00
Oliver Gierke
e48ec42be6 DATAJPA-28 - Added support for XML based metadata.
Added IsNewAware and IdAware implementation that uses JPA 2.0 meta model API to find the id field. Using that instead of JpaAnnotationEntityInformation to be able to use XML based entity mapping as well. Changed mapping of Role sample domain class to XML and created integration test to verify XML metadata is considered as well.
2011-02-23 09:59:59 +01:00
Oliver Gierke
14a69eac43 DATAJPA-29, DATAJPA-30 - Fixed invalid page metadata in pagination queries.
JpaCountQueryCreator now correctly applies the predicate. Added test cases and support for 'In' keywords.
2011-02-22 21:51:09 +01:00
Oliver Gierke
ca21bfe631 DATACMNS-15 - Applied distinct flag from PartTree to query. 2011-02-21 18:41:25 +01:00
Oliver Gierke
cd4013fe1d Fixed bug in total page number calculation due to additional root adding.
Using the initially created root to create the count projection now. Added more tests to verify correct number of elements and pages.
2011-02-14 21:44:03 +01:00
Oliver Gierke
23fd1349a3 DATAJPA-23 - Fixed query building for IsNull and IsNotNull.
Use the actually accessed path instead of the root object. Added test cases to verify behaviour.
2011-02-14 17:54:37 +01:00
Oliver Gierke
a005f0bd6e Forward ported fix of Hades bug #421.
Moved transaction configuration into JpaRepository interface and redeclared methods of Repository and PagingAndSortingRepository. This is unfortunately necessary as otherwise the custom transaction configuration inside a user's repository interface (e.g. redefining transaction configuration in findAll()) would not be considered as AbstractFallbackTransactionAttributeSource prefers implementation configuration as this is usually more specific (except in our case). This unfortunately requires the redeclaration of the methods.
2011-02-09 13:53:07 +01:00
Oliver Gierke
6b1aabfa91 Added deleteInBatch method to JpaRepository.
Reverted implementation of delete(Iterable<T> entities) to iterate over the entities as creating a query can cause the persistence provider to choke on really large entity sets. Beyond that triggering a query would require us to clear the persistence context which might not be wanted in every case. Thus an additional method deleteInBatch(Iterable<T> entities) especially available on the JpaRepository interface now triggers the query but clearly states the assumptions and side effects in the JavaDoc. Removed some obsolete finals and an obsolete method.
2011-02-03 19:57:22 +00:00
Oliver Gierke
b884e7374f DATACMNS-12, DATAJPA-15 - transaction-manager-ref is now considered
Updated to latest changes in infrastructure in Spring Data Commons.
2011-01-26 17:51:16 +02:00
Oliver Gierke
c919e2a538 DATAJPA-9 - Expose flag to disable setting dates in auditing namespace.
Auditing namespace element now has a set-dates attribute that defaults to true, but also allows disabling that in case one wants to use database set values.
2011-01-25 16:42:11 +02:00
Oliver Gierke
d108bc9fed DATAJPA-13 - findOne(Specification s) now returns null if there is no result.
I chose not to return the arbitrary first result in case the Specification returns more than one result. First, there's no way to influence the order of the results so that we potentially get different results for the very same call. Beyond that this aligns with the semantics we have for finder methods that are supposed to return a single entity but actually don't.
2011-01-21 01:50:43 +01:00
Oliver Gierke
3db9240647 Fixed premature initialization of AuditorAware implementations.
Set bean scope of AuditingEntityListener to prototype to ensure DI for each instance. Before that AuditorAware implementations referencing a Repository would cause premature initialization of those as the AuditingEntityListener gets created and thus wired when the EntityManagerFactory gets created. At that point in time we unfortunately don't have no DAOs yet.

Added @DirtiesContext to AuditingEntitListenerIntegrationTest because otherwise the @Configurable backing prototype bean definition leaks into other test cases.
2011-01-20 19:28:03 +01:00
Oliver Gierke
b6767afadc Fixed missing application of Pageable handed to query methods using query derivation from the method name. 2011-01-20 12:10:28 +01:00
Oliver Gierke
b9b245df5e Adapted newly introduced Property abstraction.
Altered JpaQueryCreator to correctly add property traversals and joins based on Property. Added integration tests to verify property traversal on collections and simple properties.
2011-01-07 22:48:53 +01:00
Oliver Gierke
d17aa75944 Updated copyright notice to reach into 2011. 2011-01-02 14:12:57 +01:00