原文:Hiberate 更新時報錯 a different object with the same identifier value was already associated with the session

使用的是Hibernate框架,Service類里有這樣一個方法: 實際執行的時候會在第 行 根據前面的條件跳轉到這里 報錯:a different object with the same identifier value was already associated with the session。 解決方法:后來改成merge 方法就可以了。 原因:從上下文來看,這里在保存前先去數據庫中取 ...

2014-12-23 19:28 1 9255 推薦指數:

查看詳情

a different object with the same identifier value was already associated with the session

這個問題,我把對象賦值為NULL,也是很好用的.在我的系統中,更新好用了,可是插入不好用了.沒改前,是插入好用,而更新不好用.本來是系統中的問題,可是,catch只是捕捉到,從但是,沒有把log打印出來,找原因實在是難找.在高度數據庫時,最好把異常捕捉中的信息打印 ...

Thu May 10 13:21:00 CST 2012 0 13327
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM