Commit Graph

43 Commits

Author SHA1 Message Date
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
Oliver Gierke
2c17f4cab1 Cleaned up license headers to align correct formatting. 2010-12-29 13:57:57 +01:00
Oliver Gierke
b50b4f573b Adapt to latest changes in repository factory base classes. 2010-12-29 13:44:36 +01:00
Oliver Gierke
f2d92cec55 Removed all references to 'DAO'. 2010-12-29 13:01:43 +01:00
Oliver Gierke
33afdbe710 Re-activated @Configurable DI in AuditingEntityListener.
Added test cases to verify setting the auditor works.
2010-12-23 17:53:47 +01:00
Oliver Gierke
c8a3e79b6e Polished JavaDoc and code.
Removed any reference to Hades from JavaDoc and code. Use a logger instead of System.out in test cases.
2010-12-23 16:02:14 +01:00
Oliver Gierke
4d1188b751 Migrated query-from-methodname algorithm to PartTree infrastructure.
Query creation is not String based anymore but rather leverages the PartTree infrastructure and builds a JPA criteria API query instead. Changed query lookup and execution accordingly.
2010-12-07 20:43:54 +01:00
Oliver Gierke
e8c5666070 Initial commit of Spring JPA repository abstraction.
Port of the Hades project whereas the JPA independent part resides in Spring Data Commons Core. Reflect changes refactorings for DATACMNS-2, DATACMNS-3, DATACMNS-4, DATACMNS-5, DATACMNS-6, DATACMNS-8, DATACMNS-9, DATAJPA-2.
2010-11-28 18:20:47 +01:00