NonUniqueObjectException异常解决办法

来源:互联网 发布:python字典转化为json 编辑:程序博客网 时间:2024/04/30 16:53

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:

 

说你在现有的Session中已经绑定了一个对象,而这时,你还要强行将已经持久化的对象再重新加入到Session中。


在一个集合中的对象,随着一对多的中一的Load而级联Load进来,这时你的另一个持久化过的对象又想利用update(),会报这个错误。


又或者当你用session.lock()时,也可能。

 

总而言之,在你的Session中,已经存在(你想要更新的)对象了。


原创粉丝点击