Heyho!

Instead of creating "changeby" / "changed" fields on all my tables, I'm 
planning to write some model classes where changes would be recorded in a 
separate "audit trail" table (the obvious benefit beyond not requiring the 
additional fields is that I can preserve the history as far back as I want)

So, like a table audit ( timestamp, dbchange, info, ...) where "dbchange" 
would be some kind of machine interpretable description and info would be a 
textual description of the event ("created user blah", "removed product x 
from order y", ...)

Where do I start to get this automated?

Session has the information about what needs to be done (insert, delete, 
update), and the model classes know what should be recorded into the audit 
records.  So where do I hook into so that I automatically can add these 
audit records at flush time?  (this would need to be after flush, actually, 
since autogenerated values need to be available.  But as long as I get into 
the same transaction I'm just fine.)

Perhaps this has even been done before?

(Obviously, this kind of audit trail would be lost upon rollback.  For a 
first variant this is fine with me; later I' guess an option to use a 
separate session for the audit stuff would be nice, but that'd need to log 
which audit records were part of a transaction that was later rolled 
back...)

Ideas & comments?

cheers
-- vbi


-- 
Bill Dickey is learning me his experience.
                -- Yogi Berra in his rookie season.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to