a different object with the same identifier value was already associated with the session
public void updateEmployee(Employee employee) {
this.getHibernateTemplate().update(employee);
}
这个错误产生原因相信大家都知道,因为在hibernate中同一个session里面有了两个相 同标识但是是不同实体,当这时运行 updateEmployee 就会出现a different object with the same identifier value was already associated with the session
解决方案:在方法里面加上employee = getHibernateTemplate().merge(employee);
public void updateEmployee(Employee employee) {
this.getHibernateTemplate().update(employee);
}
这个错误产生原因相信大家都知道,因为在hibernate中同一个session里面有了两个相 同标识但是是不同实体,当这时运行 updateEmployee 就会出现a different object with the same identifier value was already associated with the session
解决方案:在方法里面加上employee = getHibernateTemplate().merge(employee);