異常1:not-
null property references a null or transient value
解決方法:將“一對多”關系中的“一”方,
not-null設置為
false
異常2:org.hibernate.TransientObjectException: object
references an unsaved
transient instance
解決方法:
cascade="save-update,persist"
異常3:org.hibernate.QueryException: could not resolve
property
解決方法:"from Category category where
category.userID = :userID"修改為"from Category category where
userID = :userID"或者"from Category category where
category.user.id = :userID"
異常4:could not initialize proxy - the owning Session was closed
解決方法:設置
lazy為
false
另一種解決方案:
org.hibernate.PropertyValueException:
not-null property references a null or transient value:
com.bjcx.project.entity.task.Equipmenttable.ProjPortfolioID
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate
字面意思:一個不允許為Null的屬性引用了一個為Null的或者無效的值。
原因:在***.hbm.xml中的
<property name="ProjPortfolioID" column="ProjPortfolioID"
type="big_decimal" not-null="true" length="10" />
中,not-null="true",這說明屬性ProjPortfolioID 不允許為空,而在ActionForm中未給他賦值,則就為空,所以就會報錯!