保存对象报错with two open Sessions
生活随笔
收集整理的這篇文章主要介紹了
保存对象报错with two open Sessions
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
purorderService.save(newpur);
出現如下
org.springframework.orm.hibernate3.HibernateSystemException: illegally attempted to associate a proxy with two open Sessions;
nested exception is org.hibernate.HibernateException: illegally attempted to associate a proxy with two open Sessions
解決方法:
更換方法:purorderService.saveMerge(newpur);
illegally attempted to associate a proxy with two open Sessions
在session緩存中以兩個標識相同的對象
使用merge方法
merge方法在執行之前都回去緩存中找是不是有相應的記錄,也就是會有一條select語句,執行改語句的目的是為了判斷該對象是否被修改了。而update就不管這些,直接就一條update語句。
?
轉載于:https://www.cnblogs.com/mangwusuozhi/p/9565476.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的保存对象报错with two open Sessions的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SVN - 简单使用手册
- 下一篇: js获取地址栏传参