a different object with the same identifier value was already associated with **(ssh异常转)
今天在用框架更新时发现报a different object with the same identifier value was already associated wit此异常
原因:因为之前已经将该条记录取到了session缓存中,用update(游离态对象)方法时发生错误,一个游离态对象和一个持久态对象,具有相同OID,因此报错。
解决办法用merge(游离态对象),该方法应该是根据游离态对象的OID,执行select语句,将游离态对象转成了持久化对象,之后update()
但是我用的是别人的框架持久化层是不能随便修改的..尽量避免去修改内部的定义的接口..
想了想 是不是自己在action里查了一遍 然后Hibernate:session里就存在了游离对象,那么最后有拿这个对象更新的话就出错。
然后我用根据传入的对象ID 查出来赋给另一个对象然后 交替属性后 更新新的对象 竟然就可以了..(我也是这样解决的,更新对象之前,先根据ID查询)
原理不是很懂..但反正是解决了..忽忽
hibernate2.17中使用insertOrUpdate()方法 hibernate3.0以上使用merge()来合并两个session中的同一对象
注:没有尝试,根据他的意思是保存更新的时候重新new一个对象试一下保存应该就可以了
a different object with the same identifier value was already associated with **(ssh异常转)的更多相关文章
- a different object with the same identifier value was already associated withthe session异常解决方案
异常信息: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was ...
- a different object with the same identifier value was already associated with the session:
hibernate操作: 实例化两个model类,更新时会提示 a different object with the same identifier value was already assoc ...
- [转]解决a different object with the same identifier value was already associated with the session错误
1.a different object with the same identifier value was already associated with the session. 错误原因:在h ...
- 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 thesession时,一般是因为在h ...
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread---------程序报错
今天遇到了这个问题: org.hibernate.NonUniqueObjectException: a different object with the same identifier value ...
- a different object with the same identifier value was already associat
问题:这个著名的托管态update更新异常 org.hibernate.NonUniqueObjectException: a different object with the same ident ...
- 解决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错误 这个错 ...
- hibernate中一种导致a different object with the same identifier value was already associated with the session错误方式及解决方法
先将自己出现错误的全部代码都贴出来: hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> ...
- Hibernate Error: a different object with the same identifier value was already associated with the session
在执行Hibernate的Update操作时,报错:a different object with the same identifier value was already associated w ...
随机推荐
- Ubuntu刷新DNS
linux刷新dns的缓存方法是: sudo /etc/init.d/nscd restart 如果发现提示命令找不到: sudo: /etc/init.d/nscd: command not fou ...
- 两则C++知识点
返回引用遵守的两条准则: 1. 不能返回局部变量: 2. 不能返回new出的量,因为可能是临时对象. const的用法: 1. 基本数据类型的写限制: 2. 函数的传入以及返回参数: 3. 类内的数据 ...
- 使用YUM管理软件包
一.概念 YUM,全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器 ...
- Android Edittext 显示光标 获取焦点 监听焦点
Edittext java 代码控制获取焦点 EditText mEditText = (EditText) findViewById(R.id.et); mEditText.setFocusable ...
- SSIS -->> Variable
变量的特点: 1)大小写敏感 2)可见范围限制,里层可以看到外层,外层看不到里层的: 在属性窗口开启EvaluateAsExpression选项可以支持expression动态赋值变量
- NAND Flash【转】
转自:http://www.cnblogs.com/lifan3a/articles/4958224.html 以Micron公司的MT29F2G08为例介绍NAND Flash原理和使用. 1. 概 ...
- 石阶 VS 石像
山庙有尊雕刻精美的佛像,前来拜佛的人络绎不绝. 铺在山路上的石阶开始抱怨:“大家同是石头,凭什么我被人蹬来踩去,你却被人供在殿堂?” 佛像笑了笑:“当年你只挨六刀,做了一方石阶,而我经历了千刀万凿之后 ...
- 《大道至简-Team》
已经学习了<大道至简>两章,我们了解了编程的本质和“懒人”造就了方法.书中没有提供给我们编程的技巧,捷径,而是从别的方面为我们讲解了编程的精义.第三章就为我们引入了“团队”这个概念. 我们 ...
- [HDOJ1015]Safecracker(DFS, 组合数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1015 这都能过…… #include <algorithm> #include <i ...
- 如何将SQLite数据库(dictionary.db文件)与apk文件一起发布
可以将dictionary.db文件复制到Eclipse Android工程中的res\raw目录中,如图1所示.所有在res\raw目录中的文件不会被压缩,这样可以直接提取该目录中的文件.使 用 ...