save时报错:not-null property references a null or transient value

来源:百度知道 编辑:UC知道 时间:2024/06/14 13:07:34
小弟最近做一个权限分配,在保存权限时发生异常!找不到问题所在,请各位大虾帮帮忙!

错误:org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: org.struts_hibernate_spring.entity.UserRoleRight.userRight; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: org.struts_hibernate_spring.entity.UserRoleRight.userRight

// 用户权限HBM映射文件
<hibernate-mapping>
<class name="org.struts_hibernate_spring.entity.UserRole" table="user_role" catalog="database">
<id name="roleId" type="java.lang.Integer">
<column name="role_id" />
<generator class="native" />
</id>
<property name="roleName" type="java.lang.String">
<column name="role_name" length="20" not-n

save的时候userRight值为空!

你在好好检查下只存进去了没有!

提示很明显,非空的值关联了一个空值或无效的值,就是你数据库里面某个字段设置为非空了,但是传过去的是个空值,仔细检查一下