4 Replies Latest reply on Sep 8, 2008 6:40 PM by Miguel Angel Goicochea

    What's the best way to implement audit fields in entities?

    Miguel Angel Goicochea Newbie
      I have many tables on my database that have audits fields (user_cr,date_cr,user_up and date_up).

      What would be the best way to implement this in Seam? I don't want to have these fields repeated in every single entity class.

      I know how to do this using @MappedSuperClass , but that would mean that all my entities with audit fields would have to extend that class, which may be a little bit rigid, I'd like to have a class containing this fields that could be assigned as an attribute to the entity class, like:

      public AuditFields getAuditFields
      {
         return auditFields;
      }

      public void setAuditFields(AuditFields auditFields)
      {
         this.auditFields = auditFields;
      }

      Also, how could Seam help me to set the values of the creation fields and an entity is persisted to the database and update the values of the update fields when the entity is modified?