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......
字面意思:在session中存在識別符號(identifier)相同,物件卻不止一個的情況報出異常。
在網上找資料,這是使用hibernate的一個比較常見的異常,原因在於如果在同方法中多次獲取同一識別符號的物件,並進行update()或者saveOrUpdate()操作的話,在其後獲取的物件進行更新操作就會出現這個異常。
示例:
public void saveXX(){ Integer id = x; Test test = testDao.getById(id); if(xx){ Test anotherTest = testDao.getById(id); anotherTest.setName("xyz"); testDao.update(anotherTest); } test.setSex("xy"); testDao.update(test);//這行出現問題 }
如果是需要對同一物件進行處理的話,儘量還是不要這樣多次獲取物件分別取進行更新操作。
解決辦法:
1、去掉多次獲取的同一標誌的物件;
2、使用hibernate的merge方法也替換update方法也可以;
相關推薦
a different object with the same identifier value was already associated with the session
user exc factory cti lec execute with sta 兩個 錯誤提示: org.springframework.dao.DuplicateKeyException: a different object with the same identi
hibernate的報錯資訊a different object with the same identifier value was already associated with the session解決辦法
廢話不多說,直接說原因,這是在hibernate中,有2個相同型別的實體類具有同樣的主鍵識別符號,然後呼叫update或者呼叫saveOrUpdate,我朋友出這個錯的由於他想要update一條資料時,獲取主鍵時從資料庫查詢獲取,此時接收的物件的主鍵id是12,吧這個值賦給要更新入參的物件,2個物件的主鍵就都
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...... 字面意思:在session中存在識別符號(identifier)相同,物件卻不止一個的情況報出
NonUniqueObjectException: A different object with the same identifier value was already associated
org.springframework.dao.DuplicateKeyException: A different object with the same identifier value was already associated with the session : [com.ch
Hibernate經典異常:org.hibernate.NonUniqueObjectException: a different object with the same identifier
最近在用Hibernate做資料修改和刪除的時候,遇到一個Hibernate的經典異常之一: 看了將近兩天的各種部落格、論壇,花費了大量的精力嘗試了 session.evict()、session.clear()、session.merge()等部落格、論壇上的數種方法以及自己的各
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
log extension -m ins clas mac problem nbsp style 官方已經給出解決方案:https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-py
Unable to build: the file dx.jar was not loaded from the SDK folder!
eclipse 執行 android 時失敗了,提示 Unable to build: the file dx.jar was not loaded from the SDK folder!確保dx.jar這個檔案在platform-tools\lib和選擇的開發版本lib中的檔案一致就可以;我用的 Andr
解決Eclipse報錯顯示Unable to build: the file dx.jar was not loaded from the SDK folder
由於最近通過SDK-Manager更新了build-tools,當要用到dx.jar這個包時,自動呼叫最新build-tools中dx.jar,但是執行android專案時Console卻提示: Failed to load C:\Program Files (x86)\And
eclipse升級Android SDK Tool版本到25.2.5後運行項目報錯Unable to build: the file dx.jar was not loaded from the SDK folder
com 但是 概述 details bsp 更新 href unable 解決辦法 概述 由於最近通過SDK-Manager更新了build-tools,當要用到dx.jar這個包時,自動調用最新版本Android SDK build-tools中dx.jar,但是運行a
記錄eclipse出現Unable to build: the file dx.jar was not loaded from the SDK folder!問題的解決辦法
(借鑑別人的思路,算不上原創) 最近把下載了android studio2.3.3,並在裡面更新了 android SDK manager各種build-tools/platforms 以及tools,其中把build-tools從19到28的各種版本都下載更新了platf
Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
百度了各種資料,也知道是因為SDK版本和ADT版本不符合引起的,就是不知道怎樣改正,因為開啟SDK Manager.exe已經提示我source for Android SDK 安裝上了,最後其實解決方法很簡單:先卸掉 source for Android SDK,然後重灌
搭建elasticsearch叢集報錯:with the same id but is a different node instance]; ]
記錄一下在安裝 elastic-search 單機多節點是時候報錯解決方案。 [INFO ][o.e.d.z.ZenDiscovery ] [slave-one] failed t o send join request to master [{mast
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
統一 apple col convert rstp stp line methods gree <?php class Car { var $color = "add"; function Car($color="green") {
ES報the same id but is a different node instance
request exc 解決 tran enabled iam job elastics 產生 ES啟動報如下錯誤[2018-10-06×××3:12:15,871][INFO ][o.e.d.z.ZenDiscovery ] [es3] failed to sen
Android -- the project was not built due to a resource exists with a different case...
進行編碼時,工程前面莫名有個紅X,正當百思不得其解時,發現在[problems]下有如下的訊息輸出 ------ the project was not built due to a resource exists with a different case... ---
MySQL故障處理一例_Another MySQL daemon already running with the same unix socket
read mon 解決 roo blog local 啟動mysql style 處理 MySQL故障處理一例:“Another MySQL daemon already running with the same unix socket”。 [root@test-121
No row with the given identifier exists
one table 解決 any 查找 unique 關聯 java 裏的 Hibernate中No row with the given identifier exists問題的原因及解決 產生此問題的原因: 有兩張表,table1和t
The used SELECT statements have a different number of columns???
自己 lin ack -o _id strong clas 之前 不一致 今天我們組就我一個人留守在這裏修復bug了,有點小悲傷啊,他們都問我能不能hold得住啊,我當然能hold得住啊; 在看一個入庫的存儲過程中,在數據庫運行的時候是沒問題的,項目已啟動,進行入庫操作就是
後臺報錯 No row with the given identifier exists
table ide 報錯 問題 沒有 span ber 不存在 產生原因 產生原因: 數據庫表裏數據問題 分析: 有兩張表,table1和table2,table1:table2=1:n 。當hibernate查找的時候,table2裏的外鍵id2沒有與tab
No resource found that matches the given name (at 'src' with value '@drawable/right_arrow_icon').
問題:我的專案有多個版本,不同版本對應不同res資料夾: 編譯時也分了多個版本,這次當我打包eshchl版本時報錯:No resource found that matches the given name (at 'src' with value '@drawable/** 部分圖片都找