Hibernate 在 saveOrUpdate() 一个 detached object 时候会报以下错误,
通常是 Web 页面修改和保存后出现
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [domain.Director#9]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [domain.Director#9]
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [domain.Director#9]
if (object.getId() != null) {
getSession().merge(object);
} else {
getHibernateTemplate().saveOrUpdate(object);
}
觉得这种方法不是很完美,寻找更好的解决方法
修改了Dao实现