Announcement Announcement Module
No announcement yet.
@Transactional intercepts annotated method and method it calls and calls etc... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @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

  • #2
    Can you share code & Spring configuration.


    • #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?