I have some hibernation code that does an insert into a database, and when that insert completes, the custom PostInsertEventListener is launched. (This is essentially a trigger to ensure that other records are properly updated)
What I need to do is make the code inside the EventListener use the same transaction as the original insert, so if the insert is not completed successfully, the EventListener will not start.
I heard that you can use javax.transaction.SyncronizationHibernate methods and transaction.registerSyncronization()for this, but there are no usage examples anywhere I can find.
Any help is appreciated.
source
share