Chad, thanks for the idea of interceptors - I had already considered them in passing and concluded that they were a sort of database independant type of trigger. I hadn't dismissed the idea entirely, but wanted to provide a bit more auditing information than just created time and lastupdated.
I wanted to record a history of all updates not just the last - this is why I was using another table for audit data. There is a one to many relationship between each object I am trying to audit and the audit class. The problem I have is that I have a number of different classes I want to audit but only want the one table of audit data.
If I were to have a number of audit tables - one for each type of record, it would be easy, but this just seems messy and inelegant somehow. I was going to create the 'create' audit message in the constructor of the auditable class, then perhaps used the interceptor to create the 'update' audit objects.
Do you know if you can create another object in an interceptor such as an audit object which is then saved by Hibernate?
*** flash of inspiration ***
Could I subclass by audit object into the various types of audit message I want e.g.
LicencePremisesAudit extends Audit
PersonAudit extends Audit etc.
then use a the subclass mechanism (the first stategy from here
http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html
to provide a discriminator column to identify the specific audit objects for each object type?
What do you think???
Thanks
Conrad