-
Aug 20th, 2011, 12:17 PM
#1
@Transactional intercepts annotated method and method it calls and calls etc...
Spring 3 using an @Transaction(value "manager"...) <= the version that became available in spring3 to deal with multiple transaction managers at the same time.
A method is annotated as transactional in a service class (requires_new and serializable). This method transactionally needs to replace the data in a few tables. This method calls the following methods on a DAO class (not annotated) using Hibernate. The configuration does use a TibernateTransactionManager
* deleteAllData <= starts a new transaction and commits : This is the problem
* saveNewData <= starts a new transaction per row save : This is the problem
= above methods hit a couple tables all with the same transaction manager in any required annotations. The only requires_new transaction is on the toplevel service method
Have also tried this with the DAO methods annotated as (requires, serializable) and no annotations.
The problem is that the deleteAllData and saveAllData start new transactions and commit and are (verified by stacktrace debugging) intercepted with a TransactionInterceptor. To make matters worse, when the saveNewData is a method in the service that uses the DAO to save each individual class instance, each saved instance does one commit per row on the DB table (mysql5.1 with most current jdbc drivers)
* The Hibernate session is being setup specifically with flushmode.commit
-
Aug 22nd, 2011, 01:45 AM
#2
Can you share code & Spring configuration.
-
Aug 23rd, 2011, 10:59 PM
#3
Unfortunately, I cannot share the configuration files. The problem was solved by moving all annotated methods into the same class.
I have found references to it being a "bad idea" to have @transactional methods call other @transactional methods, which seems an issues. It makes sense for a method that makes REQUIRED_NEW to be able to call another method in another class that has REQUIRED on the same transaction manager and thus join the single transaction. Yes?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules