码迷,mamicode.com
首页 > 其他好文 > 详细

a different object with the same identifier value was already associated with the session.

时间:2015-07-04 16:51:48      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:org.hibernate.nonuniqueobjectexception

session.update(Object  object)方法来对数据库进行更新的。而该方法在执行时,如果在session的缓冲区中存在与传入对象object有相同id的PO对象的话,就会抛出a different object with the same identifier value was already associated with the session.


解决办法:


用hql的方式直接对数据库进行修改

super.queryHql("update Customer u set u.email = ? where u.id = ?", obj);


参考文章

http://excon.iteye.com/blog/1085591

 

本文出自 “一无所有-天行者” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1670923

a different object with the same identifier value was already associated with the session.

标签:org.hibernate.nonuniqueobjectexception

原文地址:http://tianxingzhe.blog.51cto.com/3390077/1670923

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!