1. 程式人生 > >錯誤:org.hibernate.PropertyValueException:not-null property references a null or transient value解決方案

錯誤:org.hibernate.PropertyValueException:not-null property references a null or transient value解決方案

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.zyj.test.Card.cardnum

提示很明顯,非空的值關聯了一個空值或無效的值,就是你資料庫裡面某個欄位設定為非空了,

在.hbm.xml檔案裡某個屬性的not-null=“true” 該為 false 或者將其去除
例如:

 <property name="sname" type="java.lang.String">
    <column name="sname" not-null="false" />
    </property>`