3 Replies Latest reply on Aug 17, 2010 8:48 AM by Adam Warski

    Hibernate.Envers: @Audited at @ManyToOne throws Exception

    Levi Strauss Newbie

      Hi,

       

      there are following two classes, related by manytoone-annotation:

       

      @Entity
      public class Firma {
        @Id
        @GeneratedValue
        private int id;

        @OneToMany(mappedBy = "firma")
        private List<Mitarbeiter> mitarbeiter;

        //getter und setter methods
      }

      @Entity
      public class Mitarbeiter {
        @Id
        @GeneratedValue
        private int id;

        @Audited()
        private String name;

        @ManyToOne
        @Audited(targetAuditMode=RelationTargetAuditMode.NOT_AUDITED)
        private Firma firma;

        //getter und setter methods
      }

       

      If i remove the @Audited(...) and then save a Mitarbeiter, all works ok. But with the @Audited-Annotation following exception is thrown:

      java.lang.NoSuchMethodError: org.hibernate.persister.entity.EntityPersister.getIdentifier(Ljava/lang/Object;Lorg/hibernate/engine/SessionImplementor;)Ljava/io/Serializable;
           org.hibernate.envers.tools.Tools.getIdentifier(Tools.java:67)
           org.hibernate.envers.tools.Tools.entitiesEqual(Tools.java:50)
           org.hibernate.envers.entities.mapper.relation.ToOneIdMapper.mapToMapFromEntity(ToOneIdMapper.java:71)
           org.hibernate.envers.entities.mapper.MultiPropertyMapper.map(MultiPropertyMapper.java:86)
           org.hibernate.envers.synchronization.work.ModWorkUnit.<init>(ModWorkUnit.java:48)
           org.hibernate.envers.event.AuditEventListener.onPostUpdate(AuditEventListener.java:165)
           org.hibernate.action.EntityUpdateAction.postUpdate(EntityUpdateAction.java:200)
           org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:179)
           org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
           org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
           org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
           org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
           org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
           org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
           org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
           org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
           org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
      

       

      The Mitarbeiter is saved but not in the relevant audit table.

       

      Thanks so much for any help!

      Levis