Hibernate 异常

a different object with the same identifier value was already associated with the session: 的解决
在做项目的时候也遇到这个问题org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:,
分析:1.同一个session中存在两个对象,且这两个对象相等. a.equals(b).导致session在提交更新数据到数据库中报错。
     2.不同的session取的同一个对象,并都对其进行更新,并同时提交。如:两个线程取的同一个对象。对于更新同一个对象时须放在同一个线程进行操作。

猜你喜欢

转载自nmx253.iteye.com/blog/1582281