I am trying to create a simple change log for inserts, deletes, and changes to my tables.
I am using hibernate's HibernateEventListener class along with the SaveOrUpdateEventListener and the DeleteEventListener.
This works great for saves and deletes. I would like to show new and old state for changes. So I followed the same pattern and created a MergeEventListener.
My problem is the original value is always null. I tried a PreUpdateListener and had the same result.
According to the hibernate docs the original object will be null of the object is detached.
My objects will always be detached based on the current architecture which is:
- Open one session get an object
- Place the object into a form backing bean
- Display the form to the user
- On Save or update click
- Open new session and update object
I am wondering if there is any way I can get the pre updated state of the object. My detached object is updated in the controller before the merge or preupdate event happens.
Any ideas or tips would be appreciated.
Thanks