null id in entry (don't flush the Session after an exception occurs)
来源:互联网 发布:河北经济直播软件 编辑:程序博客网 时间:2024/06/05 16:39
错误提示:
org.hibernate.AssertionFailure: null id in com.youxue.domain.Question entry (don't flush the Session after an exception occurs)
解决方法:
遇到这个异常实属不小心所致,最初看到异出的错误信息时我误认为是主键为空所致。一着急竟然把entry当成了entity理解,真是让人笑话^_^。
其实个该异常信息是在提示我们没有为数据中的非空字段设置值。呵呵!看,够笨的吧。怎么会忘记为非空字段设置值呢?当然一般我们是不会犯这样的错。但是需要说的一点是,在数据的设计中比如SqlServer,我们为某个非空字段设置了默认值。如果我们在通过Hibernate增加一条记录的时候我们必须显式的通过setXxx方法为该字段(/属性)赋值(/默认值)。因为在保存之前Hibernate会检查该非空字段对应的实体属性是否为空。我就是忽略了这一点,所以才会造成上面的异常。
如果不想对有默认值的非空字段进行显式赋值的话,我们可以通过xxx.hbm.xml配置文件来实现,也就是在配置文件中给出该字段的默认值
除了这个原因还有可能是因为数据表字段涉及到了你所使用的数据库的关键字亦或者是hirbernate映射文件中字段长度与你数据表中的长度不一致等等
希望对你有所帮助!
0 0
- null id in entry (don't flush the Session after an exception occurs)
- null id in entry (don't flush the Session after an exception occurs) 解决方法
- org.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
- null id in entry (don't flush the Session after an exception occurs)
- org.hibernate.AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
- null id in entry (don't flush the Session after an exception occurs)的错误
- null id in com.hfxt.entity.User entry (don't flush the Session after an exception occurs)
- org.hibernate.AssertionFailure: null id in xxx (don't flush the Session after an exception occurs)
- null id in XXXentity (don't flush the Session after an exception occurs。。。。(HIbernate 实体类包含关键字)
- null id in org.htss.messageservice.pojo.Task entry (don't flush the Session after an exception occur
- don't flush the Session after an exception occurs异常
- don't flush the Session after an exception occurs
- don't flush the Session after an exception occurs
- org.hibernate.AssertionFailure: null id in xxx entry (don't flush the Session after an except)解决方法
- don't flush the Session after an exception occurs 异常原因
- ssh插入信息报异常!don't flush the Session after an exception occurs
- 报错信息don't flush the Session after an exception occurs
- org.hibernate.AssertionFailure: null id in com.fy.domain.GoodPO entry (don't flush the Session after
- 三种字符串拼接方式比较
- 使用CSS居中表(四)
- MDK5.0 更新J-Link固件 导致其自动关闭 的有效解决方法
- VS多线程设置
- 深入理解java虚拟机笔记:编译与执行
- null id in entry (don't flush the Session after an exception occurs)
- C++类型转换
- 创建个人网站
- Linux 内核解读入门
- Android SDK 离线下载安装
- 七牛上传简单案例
- android开发笔记(1)
- 比较等长数组的所含元素相同,比较
- 第十三章 13.4节练习