现在的位置: 首页 > 综合 > 正文

a different object with the same identifier value was already associated with the session

2018年02月08日 ⁄ 综合 ⁄ 共 351字 ⁄ 字号 评论关闭

 a different object with the same identifier value was already associated with the session

 

错误原因:在hibernate中同一个session里面有了两个相同标识但是是不同实体。

 

hibernate session 中不允许有两个对象对应一条记录:既两个对象的id一样;

 

 

解决:清除session中的一个对象;   或者禁止生成两个一模一样的对象,只对原来的对象进行修改更新既可,不要查出一个对象,然后又new一个空对象,把查出的对象属性全部copy到 new的那个对象中;此时就冲突了;

 

 

 

有兄弟写的更详:http://yiwong.spaces.live.com/blog/cns!B3DDA7D31C386430!1233.entry

抱歉!评论已关闭.