JPA Audit Tracking
We have to store history of data changes in the DB.
We found 2 ways for doing this namely
1. Oracle Triggers
2. JPA Lifecycle Change Listeners
We do not want to use Triggers because our Architects said that in DB we should not embed program logic
We are left with JPA LifeCycleChange Listeners namely postPersist,postUpdate,postRemove
But when we use these listeners, there are 2 transactions involved.
1. If the 2nd transaction fails for some reason, then we will end up with no history
record. How can this be avoided?
2. Is it really necessary to use postPersist for all new inserts and postUpdate for data update? Is it possible to cover both with only one listener method namey postPersist?
3. Is there any other way to collect history data?