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 ...
随机推荐
- Zen Coding 用法
html:5 或者 ! 生成 HTML5 结构html:xt 生成 HTML4 过渡型html:4s 生成 HTML4 严格型 E 元素名 (div, p);E#id 带id的元素 (div#cont ...
- Netty4.x中文教程系列(五)编解码器Codec
Netty4.x中文教程系列(五)编解码器Codec 上一篇文章详细解释了ChannelHandler的相关构架设计,版本和设计逻辑变更等等. 这篇文章主要在于讲述Handler里面的Codec,也就 ...
- 查找当前SQL Server下的Active Session正连接着哪个数据库
今天碰到个事.原本想把数据库设为单用户模式然后把REMOVE FILE.没想到悲剧了.因为很多进程都是需要远程连接这个库,导致别的进程抢在我前面连接了这个数据库,反到我连不上了.想把数据库切回MULT ...
- usb协议分析-设备描述符配置包-描述符
/* usb协议分析仅供大家参考---设备描述符配置包,设备描述符, 地址设置, 配置描述符, 字符串描述符 */ /* -1- usb设备描述符配置包 */ typedef struct _USB_ ...
- AE开发 入门教程
此过程说明适合那些使用.NET建立和部署应用的开发者,它描述了使用ArcGIS控件建立和部署应用的方法和步骤. 你可以在下面的目录下找到相应的样例程序: <安装目录>/DeveloperK ...
- OpenMp之false sharing
关于false sharing的文章,网上一大堆了,不过觉得都不太系统,那么下面着重系统说明一下. 先看看外国佬下的定义: In symmetric multiprocessor (SMP) syst ...
- Objective-C 类的继承、方法的重写和重载
一.类的继承 Objective-c中类的继承与C++类似,不同的是Objective-c不支持多重继承,一个类只能有一个父类,单继承使Objective-c的继承关系很简单,易于管理程序.Objec ...
- HDU 4658 Integer Partition(整数拆分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4658 题意:给出n.k.求n的拆分方案数.要求拆分中每个数不超过k. i64 f[N]; void i ...
- C++关键字 inline
在C&C++中 一.inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义. 表达式形式的宏定义一例: #define ExpressionName(Va ...
- cocos2dx 坐标系 -转
(原文出处找不到了) 无论是搞2d还是3d开发,最需要搞清楚的就是坐标系,这部分混乱的话就没啥奔头了.所以玩cocos2d,一上来就先把各种与坐标有关的东西搞清楚. 基本的两个坐标系:屏幕坐标系和GL ...