保存实体时的Hibernate异常

时间:2014-12-09 15:30:40

标签: hibernate

我目前面临一个问题,由于某些未知原因,hibernate层引发了以下异常:

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.company.EntityForSave#12345]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1935)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2579)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2479)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2806)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)

有没有人知道这是发生了什么? 我读了很多关于这个的文章,但没有一个适用于我的情况,所以任何帮助都会非常感激!

1 个答案:

答案 0 :(得分:0)

嗯,问题是交易是重叠的。在打开的嵌套事务中,脏读数据可能会造成严重损坏。