org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier
value was already associated with the session: [netctoss.rights.domain.Role#7]; nested exception is
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already
associated with the session: [netctoss.rights.domain.Role#7]
把数据访问层的更新方法中的update 改成merge就可以实现
public void update(Role r) {
getHibernateTemplate().update(r);
}
public void update(Role r) {
getHibernateTemplate().merge(r);
}
解决HibernateNonUniqueObjectException
本文介绍了解决在使用Hibernate框架进行数据更新操作时遇到的NonUniqueObjectException异常的方法。通过将更新方法中的update操作替换为merge操作,可以避免因会话中存在具有相同标识符值的不同对象而导致的问题。
1062





