异常a different object with the same identifier value was already associated with the session 产生原因及解决
·
今天做毕设项目的时候,更新登录信息hibernateTemplate.update(entity); 时突然给我抛了个
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
一看一头2个大 ,这什么破异常 ,从没遇到过嘛遇到该异常感觉无从下手从字面上的意思来看是2个不同的对象关联到了同一个标志位,也就是说在一个session中存在2个对象但这2个对象的标志位是相同的比如2个对象的 id值是一样的 而这又是数据库的唯一主键在做更新操作的时候就出现冲突了,因为Hibernate不知道到底要去更新哪个对象出现这样的问题头都大了,后来 仔细分析了下,
更多推荐



所有评论(0)