Enhancement #301

Let GenericDao implementation be transactional

Added by Oliver Gierke 4 months ago. Updated 3 months ago.

Status:Closed Start:05/11/2010
Priority:Normal Due date:
Assigned to:Oliver Gierke % Done:

100%

Category:Core DAO Spent time: 13.00 hours
Target version:2.0.0 RC2 Estimated time:12.00 hours

Description

Currently DAO instances have to be equipped with a transactional facade to allow e.g. calls to save(…). It would be cool if we could let the instance of GenericJpaDao be transactional itself and thus allow custom DAO interfaces to work with @Transactional, too. Having that said, there are a few critical points to be considered.

  • Read-only methods should be marked as with @Transactional(readOnly=true) to trigger read only behaviour when being invoked standalone. The configuratin can always be overriden by placing a facade in front of the DAO and configure transactions there
  • Selection of the transaction manager to be used has to be configurable in the namespace configuration. Usually the transaction manager is configured using the value attribute of the annotation. This doesn't work out for us as we have to configure the TransactionInterceptor manually to use the transaction manager configured via the namespace.

Related issues

related to Hades - Enhancement #130: Hades should regard @Transactional annotation on DAO interfaces Closed 10/07/2009
precedes Hades - Task #305: Document transactionality of DAOs Closed 05/12/2010 05/12/2010

Associated revisions

Revision 10948
Added by Oliver Gierke 4 months ago

  • added @Transactional annotations to GenericJpaDao
  • references #301

Revision 10949
Added by Oliver Gierke 4 months ago

  • extended GenericDaoFactory to call prepare(…) before adding QueryExecuterMethodInterceptor
  • QueryExecuterMethodInterceptor gets reference to instance of DAO base class, too
  • QueryExecuterMethodInterceptor is now able to execute methods on the base DAO instance that were redeclared inside the users DAO interface (e.g. for altering transaction configuration)
  • GenericDaoFactoryBean now configures a PersistenceExceptionTranslatorInterceptor inside prepare(…) as well as an annotation aware TransactionInterceptor
  • extended ClassUtils to lookup DAO base class methods potentially overridden at the user's DAO interface
  • upgraded to Spring 3.0.3.BUILD-SNAPSHOT as it contains a necessary fix inside TransactionInterceptor
  • references #301

Revision 10951
Added by Oliver Gierke 4 months ago

  • forgot to commit upgrade to Spring 3.0.3.BUILD-SNAPSHOT
  • references #301

Revision 10952
Added by Oliver Gierke 4 months ago

  • adapted namespace configuration to allow configuring a transaction manager explicitly (required if multiple EntityManagerFactoryBean declarations are used
  • references #301

Revision 10953
Added by Oliver Gierke 4 months ago

  • added integration tests for transactional behaviour and configuration
  • fixes #301

History

Updated by Oliver Gierke 4 months ago

  • Status changed from New to Fixed
  • % Done changed from 50 to 100

Applied in changeset r10953.

Updated by Oliver Gierke 4 months ago

  • Target version set to 2.0.0 RC2

Updated by Oliver Gierke 3 months ago

  • Status changed from Fixed to Closed

Also available in: Atom PDF