JPA org.hibernate.ObjectException
我正在使用JPA。在运行多个事务时,我遇到以下错误 例如,添加JPA org.hibernate.ObjectException,hibernate,jpa,Hibernate,Jpa,我正在使用JPA。在运行多个事务时,我遇到以下错误 例如,添加 添加事件21 添加事件22 删除22 删除21 现在,当我进去添加一个新事件时,它表明一个不同的对象已经与这个会话关联 org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.domain.Event#22] 我想我知
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.domain.Event#22]
我想我知道发生了什么,但不知道如何解决这个问题
谢谢在重新创建删除的实体之前,您是否尝试刷新会话
session.flush();
我试着冲水,但没用。尝试合并也不能解决这个问题。我在开始交易之前尝试了清除它。这确实奏效了,非常感谢。问题是,在这个修复之后,我得到了过时的异常和索引外的属性。我想我有3个任务1)删除2)添加3)更新任务。我想如果我能修复删除部分,它可以解决问题,但仍然卡住。