在MyEclipse上运行出现异常时,经常会报如下错误:not-null property references a null or transient value:.......。这个错误的意思是,有一个属性我们设置了值不能为空,然而,项目运行时它的值为空,所以出现了异常。举个例子:
not-null property references a null or transient value: com.school.entity.Majormgr.majorName
这是说在com.school.entity包下有一个Majormgr类,该类中的majorName属性值为空。解决方法是:
找到该数据表的映射文件,即Majormgr.hbm.xml。将
中的 not-null="true"去掉即可。<property name="majorName" type="java.lang.String"> <column name="majorName" not-null="true" /> </property>
java中的异常not-null property references a null or transient value
最新推荐文章于 2023-10-10 10:51:02 发布