identifier of an instance of .. altered to null ---- hibernate exception
identifier of an instance of .. altered to null
是做Hibernate,對一條資料進行復制(新增資料)時遇到的問題
原因:
在SSH框架中,我們常常把事務放在業務邏輯層(Manager),所有業務邏輯完成後才能commit事務,這時候,如果我們從資料庫load/get一個物件出來,雖然對它寫update方法,但是在提交事務時候,hibernate仍有要把當前物件和session中物件做比較,一旦修改了該物件某個屬性,hibernate會自動執行更新操作的。
其實就是我將原來的物件Id由原來的資料【xxxx】改變為null,所以hibernate在儲存資料的時候才會報錯,hibernate在這裡監聽到的是屬性值改變,是更新而不是儲存
我原本是想再原來資料的基礎上覆制一條和他一樣的來,沒想到卻做成了修改。
解決方法:
不能直接更新已經查到的資料,要new一個物件例項,進行屬性複製(BeanUtils.copyProperties(source, dist))
擴充套件:
如果要複製的例項中,關聯到另外一個或幾個例項,此時你就要分析是哪個關聯到哪個,如果你複製的例項是被關聯,那可以不用考慮關聯,直接將該關聯屬性置空。
反之,如果不是被關聯,就要考慮關聯的問題了
相關推薦
identifier of an instance of .. altered to null ---- hibernate exception
identifier of an instance of .. altered to null 是做Hibernate,對一條資料進行復制(新增資料)時遇到的問題 原因: 在SSH框架中,我們常常把事務放在業務邏輯層(Manager),所有業務邏輯完成後才能commit事務
identifier of an instance of was altered from to null
Hibernate的提示錯誤 Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from 150 to null 原始碼如下: List<
identifier of an instance of bean was altered from 1 to 2(持久化物件ID變更)
今天遇到個怪問題,hibernate修改外來鍵id時出現: org.springframework.orm.hibernate3.HibernateSystemException: identifier of an instance of xx altered from 2
解決org.hibernate.HibernateException: identifier of an instance of com.ahd.entity.Order was altered from2 to 0
錯誤資訊 嚴重: Servlet.service() for servlet [springmvc] in context with path [/order] threw exception [Request processing failed; nested exception i
org.hibernate.HibernateException: identifier of an instance of 實體類的完整類路徑 was altered from X to X.
org.hibernate.HibernateException: identifier of an instance of 實體類的完整類路徑 was altered from X to X. 有一種可能是 上述“實體類的完整類路徑”的類 中
identifier of an instance of XXX.XXX was altered from n to n+1 異常
造成錯誤的原因是: 利用Hibernate批量新增,傳入實體類引數,這裡是用for迴圈進行批量新增;每迴圈一次,需要重新例項化實體類,但是卻將實體類例項化放在迴圈外面 解決辦法,把要進行CRUD操作
identifier of an instance of ……was alter from 2 to null
Undefined Error: org.hibernate.HibernateException: identifier of an instance of com.shkco.adsr3.staticdata.vo.ClientGroup was altered from 2 to null Li
hibernate jpa manyToOne級聯操作時,update時報出identifier of an instance of 問題的解決方案及update問題
最近一直在用Jpa來做專案,jpa的優點這裡我就不多說了,說一下最近使用時解決的一個問題吧。 首先來說,使用jpa進行update操作時,由於呼叫的是jpa封裝好的save方法,所以如果表單頁面中沒有提到的引數,這時儲存的時候,沒有提到的引數就會被置為null,為此我
解決 Unable to create an instance of type [com.sun.faces.config.ConfigureListener]
宣告:每個人的的電腦都會因為電腦環境,版本等因素不同,可能解決方法不通用,請大家多點耐心吧,畢竟是幹這行的,開始學習的時候,我搭建SSM框架很多次,有問題無法解決就重頭搭建,bug是有的,但總有一天能克服。 我遇到的問題 Caused by: org.apache.cata
開啟頁面出現Object reference not set to an instance of an object錯誤
開啟網頁出現 查看出錯的位置,如圖中紅色部分所標,因為系統之前執行正常,所以這部分程式碼是沒有問題的,出問題的函式是get name函式,開啟相應的網頁程式碼,發現 其功能是根據專業程式碼讀取專業名稱,應該就最近增加的相應資料量出現了問題,從資料庫中把相關的表格開啟檢查,果然發現,有的
scrapy+mongodb報錯 TypeError: name must be an instance of str
mongod rap 小寫 erro ror 配置文件 sta name 問題解決 經過各種排查,最後找到原因,在settings文件中配置文件大小寫寫錯了,在pipelines中 mongo_db=crawler.settings.get(‘MONGODB_DB‘),ge
執行時錯誤 terminate called after throwing an instance of 'std l
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
解決方案:terminate called after throwing an instance of 'ros::TimeNotInitializedException'
在ROS中使用ros::Time和ros::Duration時出現瞭如下錯誤: terminate called after throwing an instance of 'ros::TimeNot
Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "xxxxxxx".
在SQL SERVER 2008 R2下用Windows 身份認證的登入名建立了一個訪問ORACLE資料庫的連結伺服器xxxxx,測試成功,木有問題,但是其它登入名使用該連結伺服器時,報如下錯誤: 訊息 7302,級別 16,狀態 1,第 1 行 Cannot create an instance of
terminate called after throwing an instance of 'std::regex_error'(C++11)
#PS:要轉載請註明出處,本人版權所有 #PS:這個只是 《 我自己 》理解,如果和你的 #原則相沖突,請諒解,勿噴 最近修改一個程式,增加了一些功能,為了方便移植,要用到C++11的正則表示式(正則用起來順手)。這裡我就想說明的是:TMD,
Back Up an Instance Store Volume to EBS
Amazon Web Services is Hiring. Amazon Web Services (AWS) is a dynamic, growing business unit within Amazon.com. We are currently hiring So
Upgrade the OS of an EC2 Instance Running Windows to a Newer Version
Amazon Web Services is Hiring. Amazon Web Services (AWS) is a dynamic, growing business unit within Amazon.com. We are currently hiring So
How to start/stop DB instance of Oracle under Linux
sid dbca tracking onf status account note notes all All below actions should be executed with "oracle" user account 1. Check the stat
xcode工程編譯錯誤:"An instance 0xca90200 of class UITableView was deallocated while key value observers were still registered with it"
開始 debugger eve locate obj bsp new 列表 ade An instance 0xca90200 of class UITableView was deallocated while key value observers were still
TypeError: super(type, obj): obj must be an instance or subtype of type
父類 self 出現問題 error upper err ins 方法 sof 問題: qs = super(BnnerCourseAdmin, self).queryset() TypeError: super(type, obj): obj must be an