First of all, audit should happen only if the entity *is* modified. What duplicate records are you seeing?
Yes I do agree that. But the tables I am auditing has columns like DateModified and other trivial stuff which is making an update on the actual entity(in return causing an insert into audit table).
So, I am trying to omit such kind of updates.
Re-fetching the current entity causes Hibernate's session to flush, which causes the infinite loop. You need either to:
1. enable manual flush
2. read the old data in another tx
(both I wouldn't recommend)
or, best solution,
3. read the PostUpdateEvent.oldState array directly.
Thanks for you reply. But, Tying to access the oldState value in onPostUpdate() gave me null
Is it because the object is a detached one?. If so what should I do to fix this one
What about pre update?