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

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

 

Hibernate经常用到的一个错误。解决的方法:

 

 1.将session清空一下,因为已经有一个ID一样的对象存在于内存中了。

  session.clear();

  2.判断是否存在和更新最好分开做。

 3.还没想到

posted @ 2012-03-29 18:19  你是猴子请的救兵么  阅读(527)  评论(0编辑  收藏  举报