读书人

一个经典的hibernate异常:a different

发布时间: 2012-11-01 11:11:31 作者: rapoo

一个经典的hibernate错误:a different object with the same identifier value was already a
在自己的测试中,对同一个对象连续进行两次update时会报:org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session这个错,在网上找了下原因,原来是在hibernate中同一个session里面有了两个相同标识但是是不同实体。
解决的办法是把session.update(action);换成session.merge(action);这样就不会报错了。

读书人网 >软件架构设计

热点推荐