老问题新讨论:再论a different object with the same
来源:互联网 发布:淘宝旺旺卖家版 千牛 编辑:程序博客网 时间:2024/05/17 01:28
老问题新讨论:再论a different object with the same
(2010-07-22 01:41:34)转载▼
标签:
a
different
object
with
the
same
identifier
value
was
already
associat
分类: java和数据库- 问题:这个著名的托管态update更新异常
- 早先的发生场景:
这个异常通常发生在一个session 内对同一个数据库对象生成了多个(经常是load(id)/get(id)一个,又new+setId(id)一个),然后又对其进行了update()或者save() .
从业务逻辑的角度,经常发生在修改/更新的操作中.
- 早先的发生原因和解决手段:
解决手段也很简单,通过session关闭和事务,把相同的操作对象从session级别或者事务级别上分隔开.
- 现在问题的新变化:
- hibernate3.0以后,getCurrentSession()技术的出现,session pool的出现,session不再需要手动open,也不需要手动关闭,反而使问题复杂化
- spring TransactionManager的出现,使问题更复杂
-
a different object with the same identifier value was already associated withthe session 问题的解决:
Copy the state of the given object onto the persistent object with the same identifier.
将给定对象的state(状态,即实例属性)拷贝给到具有相同id的持久化对象
If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance.
如果当前没有持久化对象关联到session,当前对象会被加载为持久化对象,并(在update后)返回持久化对象
If the given instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not become associated with the session.
如果给定实例还没存盘,就存一份copy,并且(这份)copy返回作为新的持久化对象.而给定的对象不会再关联到session
0 0
- 老问题新讨论:再论a different object with the same
- 老问题新讨论:再论a different object with the same (2010-07-22 01:41:34)
- a different object with the same identifier
- a different object with the same identifier value
- a different object with the same identifier value
- a different object with the same identifier value
- org.hibernate.NonUniqueObjectException: a different object with the same ide
- org.hibernate.NonUniqueObjectException: a different object with the same ide
- 论a different object with the same identifier value
- 问题解决:DuplicateKeyException: a different object with the same identifier value
- 解决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
- 学习Handler的一些用法
- ubuntu 乱码,时间不显示,
- 全面踏上OpenStack应用之旅(前言)
- 深入理解Android
- 2015年上海邀请赛 第一次赛前集训 小结
- 老问题新讨论:再论a different object with the same
- 微信聊天记录查看器(程序+源码) - iOS版
- [外文资料]利用SharedPreference管理Session
- 杭电ACM 2031: 进制转换
- HP 服务器阵列快捷键
- java中静态代码块的用法 static用法详解
- WDCP控制面板打开空白或无法登录的解决办法
- POJ 2409 Polya组合
- 银联IC卡读卡流程详解--读卡器与卡交互指令