1 Reply Latest reply on Feb 2, 2011 2:23 AM by adamw

    Envers Usage for "Audit Log"

    sepp_huber

      Hello,

       

      I am new to Envers and I have a general question of the usage:

       

      We have the requirement in our application that changes on some objects should be journalized - the "audit log" concept.

      Not a requirement is to restore old versions - the "audit trail" concept.

       

      A solution for this could be a central database table, which is filled HibernateInterceptors or with Database-Triggers and stores:

      -Classname

      -ID

      -fieldName

      -oldValue

      -newValue

      -changeDate

      -changeUser

      -operation (insert, update, delete)

       

      A solution for this with HibernateInterceptors is described here http://community.jboss.org/wiki/AuditLogging

       

      Is this also possible with Envers? The usage of the annotations is very convenient ...

       

      We also need to provide a frontend for the audit-log.

      In Envers we have to find out the changes with comparation of two successive versions, perhaps timeconsuming.

      This would be much more simple with one audit-log table.

        • 1. Envers Usage for "Audit Log"
          adamw

          No, Envers doesn't support the central-table concept. However you could quite easily leverage quite a lot of Envers code to achieve that (change the mapping and the work units).

           

          Also, even with the central-table concept, I think it would be good to separate it into two: data and revision info, so that you can group changes made in one tx/by one user at a time easily using a foreign key.

           

          As for comparing two versions, it's a matter of comparing the fileds in two entities - this can be time-consuming if you've got very large entities .

           

          Adam