views:

54

answers:

1

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.(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)

What's the problem?`

Thanks so much! Levis

A: 

Check that the jars used at runtime are at the same version than the jars used to compile your code.

If it doesn't solve your problem (and most likely, it won't), put the jars provided with Hibernate Tools in your classpath, instead of the ones you're using right now. Technically, thi can happen if one of the jar you're using contains classes that have been compiled using a specific version of another jar, which differs from the one you have in your classpath.

Samuel_xL
Thanks for your answer! But how to do this? Which directories are relevant?
Levis