报错信息:Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier

来源:互联网 发布:lte mrr弱覆盖优化 编辑:程序博客网 时间:2024/04/30 12:40

报错信息:Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.lbs.syebx.common.entities.Jc02#3000551332]
报错信息截图
这是由于hibernate在使用find或者get方法查询到一个实体时,你又向这个实体赋值,本例中是jc02,如图这是我修改后的代码
只是在查询出来的时候,加了一句话:hibernate.evict(jc02);
这句话的主要作用是使对象jc02从持久化状态转换为游离状态,然后就能向session中加入新的jc02了。

0 0
原创粉丝点击