1. 程式人生 > >hibernate常見錯誤及解決方法總結

hibernate常見錯誤及解決方法總結

1、org.hibernate.PropertyNotFoundException: field [cid] not found on org.sihai.shop.categorySecond.CategorySecond

解決:一般是在hbm.xml檔案中的屬性和實體中的屬性不對應

2、org.hibernate.MappingException: An association from the table product refers to an unmapped class: CategorySecond

解決: class需要寫全路徑

3、mysql刪除有外鏈索引資料
Cannot delete
or update a parent row: a foreign key constraint fails erty references a null or transient value: org.sihai.shop.product.Product.categorySecond; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: org.sihai.shop.product.Product.categorySecond

解決:在做刪除的時候,因為直接獲取到的物件是瞬時態的物件,不是持久態,不能刪除,所以需要在刪除的時候,先根據id查詢到這個持久態的物件,然後再刪除。
// 後臺:刪除商品
public String delete() {
product = productService.findByPid(pid);
productService.delete(product);
return “deleteSuccess”;
}

6、object references an unsaved transient instance - save the transient
instanc

解決:需要設定級聯的物件cascade = “sava-update”,這樣才會儲存級聯的物件。主要的問題在於沒有給其物件設定id值,這樣的話儲存的時候不是一個持久化的物件。

7.Field 'uuid' doesn't have a default value

解決:這是由於在設計表的時候忘記給其主鍵設定自增了。

8. org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:

解決:這是因為沒有配置實體類的對映檔案造成的。

相關推薦

hibernate常見錯誤解決方法總結

1、org.hibernate.PropertyNotFoundException: field [cid] not found on org.sihai.shop.categorySecond.Cat

web程序常見錯誤解決方法

開始 個數字 ice 依據 文件中 方法參數 500錯誤 程序 運行 404錯誤產生原因及解決方法 在剛開始進行Web應用開發的時候,經常看見頁面出現404這個數字,我們一般會稱之為運行產生了404錯誤。類似於404這個數字,還有可能在頁面上看到405、500這兩個數字,他

jenkins 常見錯誤解決方法整理

ref 令行 follow ESS tro windows ins 常見錯誤 以管理員身份運行 現象 WMI.WmiException:AccessDenied 解決方法: 以管理員身份運行 cmd 命令行 jenkins-slave install jenkins

ENVI FLAASH大氣校正常見錯誤解決方法(轉載)

ENVI FLAASH大氣校正常見錯誤及解決方法(轉載) 本文彙總了ENVI FLAASH大氣校正模組中常見的錯誤,並給出解決方法,分為兩部分:執行錯誤和結果錯誤。前面是錯誤提示及說明,後面是錯誤解釋及解決方法。 FLAASH對輸入資料型別有以下幾個要

nginx常見錯誤解決方法

nginx: [error] open() “/var/run/nginx.pid” failed (2: No such file or directory) 今天修改了下nginx配置,重新載入配置檔案的時候報瞭如下錯誤 [root@renguangli ~]# nginx

java中在使用類時的一些常見錯誤解決方法

關於java中類的一些常見錯誤及解決方法 1.定義了一個主類,如 public class TestCircle{//此時這裡會顯示“class TestCircle”has never been used“ public void main(String[] args){…}; class

Linux下編譯PHP常見錯誤解決方法

locate freetype evel distrib 常見 expec fin install erro 1、configure: error: xml2-config not found. Please check your libxml2 installation.

loadrunner執行場景時,常見錯誤解決方法

目錄   1、Error -27727:.3 2、Error -27728:.3 3、Error -27791:.3 4、Error -27492:.4 5、Error -27498:.4 6、Error -26612:.4

mysql主從同步常見錯誤以及解決方法總結

前言 在發生故障切換後,經常遇到的問題就是同步報錯,資料庫很小的時候,dump完再匯入很簡單就處理好了,但線上的資料庫都150G-200G,如果用單純的這種方法,成本太高,故經過一段時間的摸索,總結了幾種處理方法。 生產環境架構圖 目前現網的架構,儲存著兩份資料,通過非同步複製做的高可用叢集,

LR執行場景時,21種常見錯誤解決方法

1、Error -27727: Step download timeout (120 seconds)has expired when downloading resource(s). Set the“Resource Page Timeout is a Wa

HTML三大選擇器的使用和命名方式,優先順序,以及選擇器中常見錯誤解決方法

HTML中的三大選擇器1.標籤選擇器:使用標籤的名稱作為選擇器,選中標籤設定樣式, 特點:可以選中多個標籤,給一堆標籤同時設定樣式書寫方式 標籤名{ 樣式 }2.類選擇器:在標籤中利用class屬性設

ros_arduino_bridge功能包集的使用錯誤解決方法總結

歡迎廣大網友批評指正,如需轉載請註明出處。 未能啟動arduino_node節點 在你使用roslaunch ros_arduino_python arduino.launch啟動該節點之後,可能會遇到下面的錯誤: ERROR: cannot

jira系統常見問題解決方法總結

一、索引異常 (http://bbs.csdn.net/topics/390747826)       錯誤日誌:   Caused by: com.atlassian.jira.issue.index.SearchUnavailableException: com.at

初學Maven常見錯誤解決方法

一、匯入新maven專案後,pom.xml可能出現以下情況:     Cannot upgrade/downgrade to Dynamic Web Module 3.0 facet. It is incompatibile with already installed f

jsp常見錯誤解決方法

僅供參考 1 臨時應答1xx 臨時應答,也就是訊息性質的應答,標誌了對方伺服器正在處理請求,並且還沒有決定最後的應答。如果伺服器處理請求需要花200ms以上才能產生終結應答的時候,它應當傳送一個1xx應答。注意1xx應答並不是可靠傳輸的。他們不會導致客戶端傳送一個ACK應答

JPA系列--JPA部署階段常見錯誤解決方法(持續更新)

錯誤一:javax.persistence.PersistenceException: Unable to locate persistence units問題 1.問題詳述 1.1 persistence.xml配置檔案 <?xml versi

Ubuntu 常見錯誤解決方法——長期不定時更新

1. 修復 /etc/sudoers 檔案損壞導致不能使用 sudo 命令 這是之前錯誤地編輯了 /etc/sudoers 這個檔案導致的,因此撤銷編輯即可,但由於已經不能使用 sudo 命令,因此不

Android 開發常見錯誤解決方法集錦

                                                 作者:段興               2014-5-24 1    DescriptionThe container 'Android Dependencies' refe

C++常見錯誤解決方法,持續更新

1.undefined reference to `[email protected]'| 可能的原因是程式沒有主函式導致的編譯錯誤 2.#include<iostream> #include<string> using namespac

專案常見錯誤解決方法-http狀態碼,對應解決方法

把在公司專案中遇到的不同http狀態碼,對應的解決問題,總結下(使用的都是Restangular): 1. 403 forbidden ,刪除操作,發現是對應的介面寫錯,(很奇怪,沒有報404,竟然是403),正確的寫法是--$rootScope.BaseUrl+"/cmd