4 Replies Latest reply on May 24, 2013 3:27 AM by Raimund Klein

    Partial auditing with MappedSuperclasses

    Raimund Klein Newbie

      Hi everyone,


      We're taking our first steps in auditing with Envers, but seem to have hit a dead end.


      Here's the basic situation: All our entities consist of two parts: one @MappedSuperclass (called <Entity>Base) which holds all properties including the relations (along with the appropriate JPA annotations) + getters and setters and the actual @Entity (class name <Entity>) which holds additional business methods. Why we're doing it this way? So that we can generate the base classes (along with other stuff that we need) out of a metamodel.


      Now we only want to audit some of the entities, but just can't get the relations to work out fine. What we've tried so far:


      1. a) Only annotating the actual entities with @Audited. Then Envers doesn't do anything.

          b) Adding the @AuditOverride annotations. Then Envers rejects the relations as these are pointing to the real entities (not the base classes) and some of them are not audited.

      2. a) Adding the @Audited annotations to the base classes along with @Audited(target=NOT_AUDITED) to the relations. Again, Envers is not really interested in this and just doesn't do anything.

          b) Adding @Audited and @AuditOverride to the real entities again. Then we have the same complaints about not audited entities in relations.

      3. Instead of annotating the attributes, we tried it with the methods so as to possibly override these in the real entity classes. This already upsets the JPA validation, as the attributes are of the real entity types and it claims the relationship's mappedBy-attribute is pointing to the wrong type.


      I've been bugging myself around with this for 3 days now, but just can't get it right. Maybe someone else has an idea. Right now, we've come to the conclusion that we have to rely on database triggers.


      We're using Jboss-as-7.1.1.Final with hibernate-core-4.0.1.Final and hibernate-envers-4.0.1.Final.


      Nachricht geändert durch Raimund Klein