We have an audit system using a hibernate interceptor and triggers. The tables that are audited contain an audit info record containing admin information and a timestamp. These fields are updated in the audit interceptor and the triggers are responsible for archiving the relevant data.
This system is similar to what is outlined here:
http://blog.hibernate.org/cgi-bin/blosxom.cgi/2004/06/19
This works fine for inserts (org.hibernate.Interceptor.onSave) and updates (org.hibernate.Interceptor.onFlushDirty). My question is about deletes. The api documentation for the org.hibernate.Interceptor.onDelete method makes a recommendation not to change the data state:
Quote:
"It is not recommended that the interceptor modify the state."
No further explanation is offered. So, if the state can not be modified, this pattern can not be used for deletes because the audit info can not be added. Going against the recommendation, I have tried adding the audit info in the onDelete method. It caused the delete to be preceded by an update. This may be a performance concern, but it did not seem to cause other problems.
Can anyone provide some insight into why the recommendation is made?
I am using hibernate 3.1.2 and oracle 10.2.
Thanks...