null id in XXXentity (don't flush the Session after an exception occurs。。。。(HIbernate 实体类包含关键字)
来源:互联网 发布:java int转string方法 编辑:程序博客网 时间:2024/05/21 02:35
insert into t_XXX (url, describe, desc) values ('aa', 'bb', 'cc'');
如上:describe与desc为数据库关键字,一旦使用为字段名就会抱null id 这样的错;
网上还有人说其他原因:
- 据库与映射文件不对应,数据库设置了不为null,但hibernate里的映身文件设置了为null。就是说在数据的设计中比如mysql,我们为某个非空字段设置了默认值。如果我们在通过Hibernate增加一条记录的时候我们必须显式的通过setXxx方法为该字段(/属性)赋值(/默认值)。因为在保存之前Hibernate会检查该非空字段对应的实体属性是否为空;
- id不是autoincrement(个人觉得不会);
- 其他原因。
总结: 我个人碰到这个问题的原因是字段使用了关键字,网上找了许久都是说其他原因的,所以总结一下,方便自己mark下。
解决的方法:1.hibernate实体类添加@Column(name="`desc`")注解在关键字加上··(鍵盤ESC下方,1左方的按鈕,~那個符號的按鈕);
2.改desc等关键字为其他非关键字的字符;
0 0
- null id in XXXentity (don't flush the Session after an exception occurs。。。。(HIbernate 实体类包含关键字)
- org.hibernate.AssertionFailure: null id in 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)
- 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 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 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)
- 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
- null id in org.htss.messageservice.pojo.Task entry (don't flush the Session after an exception occur
- 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
- Edit distance problem 动态规划和递归解法之比较
- 数据库范式(1NF 2NF 3NF BCNF)详解一
- MySQL my.cnf参数配置优化详解
- Linux学习记录--进程控制相关系统调用
- CSS之float在IE浏览器下换行问题
- null id in XXXentity (don't flush the Session after an exception occurs。。。。(HIbernate 实体类包含关键字)
- 解决网络ping内外网成功,但浏览器等应用程序连不上网(视个人情况而定)
- Git 常用命令整理
- 【极客学院每日一课】Android系列之一:创建和使用Android模拟器
- 动态规划
- struts2--package配置
- linux后台开发必看书
- (android中的动态布局)关于Android下各个布局方式里面LayoutParams的用法
- Hibernate版本 支持 hibernate-jpa-2.0-api-1.0.0.Final.jar