Announcement Announcement Module
Collapse
No announcement yet.
Does JtaTransactionManager support beforeCompletion synchronization? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does JtaTransactionManager support beforeCompletion synchronization?

    I'm using the JtaTransactionManager -- how do I register a beforeCompletion() synchronization on my transaction?

    I've done this using the HibernateTransactionManager and there I just call session.getTransaction().registerSynchronization() , but I don't how to do it with the JtaTransactionManager.

    Does Spring support this?

    Thanks,
    -Daniel-

  • #2
    You can use Spring synchronization mechanism:

    Code:
    TransactionSynchronizationManager.registerSynchronization(TransactionSynchronization synchronization)
    or JTA synchronization mechanism:
    Code:
    TransactionManager#getTransaction()
    Transaction#registerSynchronization(Synchronization)
    Look at: SessionFactoryUtils#getJtaSynchronizedSession

    Comment


    • #3
      I see this in the SessionFactoryUtils javadoc:
      Note that for non-Spring JTA transactions, a JTA TransactionManagerLookup has to be specified in the Hibernate configuration.
      We have not specified a TransactionManagerLookup. That might be the problem. Thanks for the pointer!

      Comment


      • #4
        I found the solution: I needed to set the hibernate.transaction.manager_lookup_class and hibernate.transaction.factory_class properties in the Hibernate config, as stated on the Hibernate Sessions and transactions Wiki page.

        Thanks for getting me headed in the right direction, Andrei!
        -Daniel-

        Comment


        • #5
          Great.

          I have looked at LocalSessionFactoryBean source. These properties are set into hibernate config when TransactionManager injected to it. It is possible to find TransactionManager via JNDI or use embedded and inject into LocalSessionFactoryBean. The result should be the same.

          Comment

          Working...
          X