Hibernate报错:
not-null property references a null or transient value:。。。。。。
一个不能为空的属性引用了一个空值或游离状态的值.
如:
有不为null的字段在删除时却为null,就报这种错误 了
方案1、将.hbm.xml文件中cascade设成all,也就是父表记录删除,与父表关联的子表记录都删除(根据具体情况来取舍)
方案2,删除父表时,先解除子表与父表的关联关系,再删除父表记录(根据具体情况来取舍
异常1:not-
null property references a
null or
transient value
解决方法:将“一对多”关系中的“一”方,
not-null设置为
false(参考资料:http://www.thearcmind.com/confluence/pages/viewpage.action?pageId=212)
异常2:org.hibernate.TransientObjectException: object references an unsaved transient instance
解决方法:
cascade="save-update,persist"(参考资料:http://www.laliluna.de/254.html)
异常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"
(参考资料:http://www.laliluna.de/277.html)
异常4:could not initialize proxy - the owning Session was closed
解决方法:设置
lazy为
false(参考资料:
http://forum.springframework.org/showthread.php?t=27993)
<script type="text/javascript"></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
分享到:
相关推荐
Spring-HBERNATE Spring -hibernate 与 mysql Spring-HBERNATE
NULL 博文链接:https://xhfei.iteye.com/blog/691322
毕业设计spring+struts2+hbernate博客系统源码+部署文档+论文
struts + DAO + Hbernate的脚本
The versions are not required strictly. You can change them base on the environment of you develpment, but you have to configure the "CLASSPATH File" property. Install step: 1 Build two java project ...
Hbernate的有源码的文件,可以帮助你学好hbernat
自己昨晚上写的 但是没有加入验证码验证机制 数据库 chat 表名user 字段 id name pass
一个完整的工程,主要功能为:spring+hbernate对clob、blob字段的处理 包括:数据脚本、典型的SSH框架处理,以及spring、hibernate数据批量保存等功能源码、所用到的lib包 数据环境为:oracle 10G 开发:Mycelipse5.1...
hibernate一份不错的文档,比较适合开始学习或者不熟练hibernate的朋友
集合struts,spring,hibernate三大框架开发,是一个很好的项目实例
一个简单的Struts+Spring+Hibernate的登录模块的代码,含数据库代码和部分简单说明(适合刚接触Struts+Spring+Hibernate框架的开发者); 本例采用myEclipse6.0.1和tomcat6开发,可直接导入myeclipse工程运行...
这个是最新版的hibernate压缩包,2016年传智播客的工具包
Hibernate3.2官方中文参考手册PDF,以及Hibernate3.2.jar
最近入职一家公司,使用的 是springmvc框架,之前公司是用的struts2没接触过springmvc,所以这几天学习了一下并写了一个简单的基于注解的demo,数据库用的mysql,就两张表,有外键关联,demo实现了两张表的级联增删...
hibernate hibernate
用于配置hibernate.cfg.xml和相当的应用,值得看看.........
使用Hibernate的一个完整例子 这是我学习的时候下载的,看着不错 喜欢的可以下载 不要分 但愿能帮到你们
自己用myeclipse开发工具写的一个sh的留言板,包括源代码和jsp页面(jsp页面写的很简单)
struts+hibernate留言板(sh) list分页技术
struts+hibernate+spring 增删改查实例,非常适合初学者