数据库更新记录报错:
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);
}
标签:different,already,associated,update,value,session
From: https://blog.51cto.com/u_2544485/7395918