-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hook before transaction commit?
PostPosted: Wed Jul 31, 2013 7:31 am 
Newbie

Joined: Wed Jul 31, 2013 5:10 am
Posts: 3
Hi everybody!

We're trying to build a change logging mechanism for an EJB application.
The mechanism is meant to log changes on entities to a logging table using native SQL whenever a transaction commits.

What we currently do is have event listeners, such as PostUpdateEventListener or PreCollectionUpdateEventListener, collect all the changes and cache them in memory to be written to the logging table in one run right before the transaction commits.

Now we're searching for a way to hook into the transaction commit phase at the right time.
We did try the FlushEventListener to execute the logging code, which works fine as long as there is no other flush than the one at the end of the transaction.
We also came across the TransactionObserver that can be added to the TransactionCoordinator, but we are not sure if this is the proper mechanism.

Any ideas on how to achieve this are appreciated!

Reis


Top
 Profile  
 
 Post subject: Re: Hook before transaction commit?
PostPosted: Wed Aug 07, 2013 2:44 am 
Newbie

Joined: Wed Jul 31, 2013 5:10 am
Posts: 3
I've kind of succeeded with the TransactionObserver in terms of that its beforeCompletion(...) method seems to be called at the right time for our purposes.

But I'm still looking for the right place to register the TransactionObserver on the TransactionCoordinator (currently I do it in each of the onPre...(...) event listener methods).

And most of all:
I need to get informed about a transaction that rolls back, so I can clear some transaction-specific caches.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.