A different object with the same identifier value was already associated with the session错误解决方法
来源:互联网 发布:mac 免密码登录 编辑:程序博客网 时间:2024/06/06 07:43
错误:A different object with the same identifier value was already associated with the session
今天又碰到这个错误,知道是怎么回事但是忘记在哪儿写过改正代码了,为了避免下一次再找不到,就写到这里吧。
这个错误产生的原因是因为在hibernate中同一个session里面有了两个相同标识但是是不同实体.也就是说内存中存在两个id相同的实体造成冲突,(我在修改实体之前又一次查询操作,这时内存中有一个实体,当修改完成保存时又会提交一个相同id的实体,因此就会存在两个标识相同的实体)系统不知道该调用哪一个实体因此而报错。
解决方法:
清理掉内存中已存在的实体即可,相关代码如下:
public voidupdateByMerge(User user) { Session session = getHibernateTemplate().getSessionFactory(). getCurrentSession(); session.clear(); session.update(user); }
- A different object with the same identifier value was already associated with the session错误解决方法
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- a different object with the same identifier value was already associated with the session错误
- a different object with the same identifier value was already associated with the session错误
- 解决a different object with the same identifier value was already associated with the session错误
- 使用Pull解析器读取XML文件和生成XML文件
- Webkit之网络模块
- Wince 6.0 教程---第五课.更改任意文件夹路径
- 图解 Linux 内存管理 -- 线性空间与物理内存
- Android 各版本代号 & Java Source Download
- A different object with the same identifier value was already associated with the session错误解决方法
- Jquery EasyUi dateGrid 自适应浏览器宽度
- 继续求大offer
- WinCE中BSP的Clone
- Android应用程序四大组件之Activity入门
- WINCE 任务栏的显示隐藏
- Android Intent.ACTION_CHOOSER 与 Intent.ACTION_PICK_ACTIVITY
- 驱动向应用程序发送消息
- java 反射