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
|