I've implemented an AuditLogInterceptor similar to the one in HIA.
Like the example, I have an explicit flush call, so that the audit data will be created in postFlush, and then will be persisted at the end of the transaction.
There is one minor annoyance I am encountering with this model. When the transaction ends, not only is the audit data begin persisted as desired, but the domain object is being updated again even though it has not been updated since the explicit call to flush. I believe that this is happening because the domain object has a <timestamp> for managed versioning, and so Hibernate is detecting that the entity is dirty simply because the timestamp was updated during the last update.
Is there any way I can get rid of this unnecessary update ?
Thanks.
|