org.hibernate.PropertyValueException: not-null property references a null or transient value: model.

來源:互聯網
上載者:User

標籤:io   ar   使用   strong   檔案   資料   on   問題   cti   

今天在寫一個SSH整合的項目時,首先將資料庫操作部分單獨分離出來,寫完後使用Junit進行測試,經過測試,發現沒有任何問題,對資料庫中的內容進行增刪改查沒有問題,但是將他整合到SSH的項目中時,報出了這麼一個錯誤org.hibernate.PropertyValueException: not-null property references a null or transient value: model.TransactionRecord.remark。當時很是費解,因為當時當時在Junit中測試的時候沒有任何問題,但是將代碼複製到項目中就會出錯了呢。當時沒有仔細看錯誤堆棧資訊,看到一個not null就以為可能是參數傳遞時候出了錯,然後在調用方法時將參數全部列印輸出一遍,但是神奇的是參數沒有任何問題,那麼問題來了,參數和方法都沒有問題到底是哪裡錯了呢?靜下心來吧錯誤資訊重新閱讀以下,錯誤的意思是在TransactionRecord這個類的remark屬性是空,引發了這個異常,然後檢查了一下對應檔,發現在對應檔中為remark這個屬性設定了一個not-null屬性為true,然後使用TransactionRecord時沒有給remark賦值。將remark的not-null屬性去除或者給remark賦值後在運行,這個錯誤就消失了。

org.hibernate.PropertyValueException: not-null property references a null or transient value: model.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.