Results 1 to 3 of 3

Thread: Hibernate transaction events in Spring

  1. #1
    Join Date
    Dec 2005
    Posts
    2

    Default 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?
    Pekka Enberg
    Reaktor Innovations Oy

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Dec 2005
    Posts
    2

    Default

    I implemented a post interceptor for TransactionProxyFactoryBean which does the registerSynchronization() call now. Thanks for the help!
    Pekka Enberg
    Reaktor Innovations Oy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •