Hibernate 删除指定行的时候出现:
Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
在stactoverflow上面看到相关解答:
Your problem is that the object you previously loaded still exists in you hibernate session. I see two ways to cope with that.
1.) tell the hibernate session to merge your modified object with the one in the session
session.merge(object)
2.) kick the old object out of the session before writing the updated object to the session. session.clear() might work.
意思是说之前load的object在hibernate session中还存在。
在删除操作之前,加上session.clear(),然后就可以了。
Hibernate Error: org.hibernate.NonUniqueObjectException
猜你喜欢
转载自lliu26.iteye.com/blog/1758468
今日推荐
周排行