Announcement Announcement Module
Collapse
No announcement yet.
Hibernate transaction events in Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate transaction events in Spring

    Hi,

    I am implementing an event queue for the Hibernate event system for my application. I want to delay the dispatching of events to a point where Hibernate session has been flushed but the transaction has not yet committed so I can start a new session which then does some updates. Basically, I want an update to a domain object trigger an update to its children.

    I know I can use the TransactionSynchronization interface to catch before commit and after commit events but how can I get begin commit events? I tried overriding doBegin of HibernateTransactionManager but it is called before transaction synchonization is initialized, so I cannot call TransactionSynchronizationManager.registerSynchron ization() there.

    Is there a way to receive transaction begin events from Spring?

  • #2
    Indeed TransactionSynchronization contains a contract related to the ending of a transaction not the beginning.
    If you are using the TransactionProxyFactoryBean you can add a pre or post interceptor which will be called just before or just after the transaction interceptor - see the javadocs for more details.

    Comment


    • #3
      I implemented a post interceptor for TransactionProxyFactoryBean which does the registerSynchronization() call now. Thanks for the help!

      Comment

      Working...
      X