0
点赞
收藏
分享

微信扫一扫

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


数据库更新记录报错:

a different object with the same identifier value was already associated with the session: [com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007]

临时解决办法:

在update之前先调用:  this.getHibernateTemplate().getSessionFactory().getCurrentSession().clear();

 

网上另有解决方法:

把数据访问层的更新方法中的update 改成merge就可以实现

public void update(Role r) {
  getHibernateTemplate().update(r);
 }
  
public void update(Role r) {
  getHibernateTemplate().merge(r);
 }

举报

相关推荐

0 条评论