Hibernate.Envers:@MudToOne @Audited抛出异常

时间:2010-08-16 18:07:59

标签: hibernate hibernate-envers

有以下两个类,由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
}

如果我删除@Audited(...)然后保存Mitarbeiter,一切正常。但是随着@Audited-Annotation引发异常抛出:

  

java.lang.NoSuchMethodError:   org.hibernate.persister.entity.EntityPersister.getIdentifier(Ljava /郎/对象; Lorg /休眠/发动机/ SessionImplementor;)Ljava / IO /串行化;     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)

有什么问题?`

非常感谢! Levis的

1 个答案:

答案 0 :(得分:1)

检查运行时使用的jar是否与用于编译代码的jar版本相同。

如果它没有解决您的问题(并且很可能,它不会),请将Hibernate Tools提供的jar放在类路径中,而不是现在使用的那些。从技术上讲,如果您使用的jar中包含一个使用另一个jar的特定版本编译的类,则会发生这种情况,这与您在类路径中的类型不同。