I am implementing a simple audit log functionality using hibernate event listeners. I wanted to accumulate all the changes for all entities in a transaction and handle auditing.
By using hibernate interceptors approach we have postFlush() where we handle auditing of all the accumulated audit events.
What is the equivalent for event listeners?
I tried using ‘hibernate.ejb.event.flush’ event. But it invokes very beginning of the life cycle, even before onPostInsert, onPostUpdate and onPostDelete events. So cannot accumulate changes.
Also tried with auto-flush, it also didn’t work. Any idea?
Just not to misled others, I figured it out that flush event listener actually works. The problem is default hibernate event listeners are not registered. When I register default event listeners along with custom listener, it started working fine.