org.hibernate.AssertionFailure: null id in xxx entry (don't flush the Session after an exception occurs)
网上找了很久,发现造成原因有很多种,后来终于发现了端倪;看提示是发生了异常,查看业务代码,发现有这个逻辑:先插入记录,如果有唯一键约束异常(并发造成),catch时查询已存在的记录,查询的时候就报了此错误。
原因:异常后,再次查询的时候触发了autoFlush,先前保存失败的记录会再次保存,导致抛出如标题所述异常。
解决方法:数据库是mysql,改为采用 insert ignore into语句进行插入
当然有很多处理方法,就不赘述了
org.hibernate.AssertionFailure: null id in xxx entry (don't flush the Session after an exception occurs)的更多相关文章
- 报错:org.hibernate.AssertionFailure: null id in com.tt.hibernate.entities.News entry (don't flush the Session after an exception occurs)
在使用hibernate创建数据库的表格时,出现了如下报错: 十二月 28, 2016 10:17:02 上午 org.hibernate.tool.hbm2ddl.SchemaExport perf ...
- 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 xxx.xx.xx的问题
今日在开发时遇到一个比较奇怪的问题,保存时报这个异常: org.hibernate.AssertionFailure: null id in com.aa.TShoucang null id,这个是什 ...
- null id in entry (don't flush the Session after an exception occurs) 解决方法
最近在学习基于ssh的注解的系统,然后在实现往数据库增加记录时可以增加第一个,第二个就报错,在网上查了很多资料,大多都是 该异常信息是在提示我们没有为数据中的非空字段设置值. 然后就一直没有明白 明明 ...
- org.hibernate.AssertionFailure: null id in com.you.model.User entry (don't flush the Session after a
1.错误描写叙述 org.hibernate.AssertionFailure: null id in com.you.model.User entry (don't flush the Sessio ...
- org.hibernate.AssertionFailure: null id don't flus
我的是字段编码和数据库不匹配,是爬的微博数据
- org.hibernate.AssertionFailure: null id 错误
对象属性有Blob类型: 而Blob需在输入流中读取: InputStream in = new FileInputStream(url.getFile()); Blob bookPic = lobH ...
- null id in com.rocky.** entry 错误处理
1. 概述 使用hibernate往mysql数据库插入记录出错如下 10:37:57,364 ERROR [AssertionFailure] an assertion failure occure ...
- org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.chen.vo.Dept.parentId
异常描述:执行以下的addAsHaveParentId2方法出现此异常: /*-----------------------类Dept.Dept.hbm.xml有parentId属性(数据库中有此列) ...
随机推荐
- js的原型/原型链/构造函数
js里一切皆对象.有js自己内部的对象,还有用户自定义的对象.所有的对象都是从原型上衍生出来的. 原型本身也是对象,原型链的最高层就是Object. 两个重要的属性:prototype, __prot ...
- Vue-CLI3.0版本配置BootStrap的方法
一.引入jquery bootstrap popper 用 cnpm install jquery bootstrap@3 popper.js --save 用cnpm 来导入 用npm会出 ...
- 【C#】【对象转XML】xml序列化
笔记:xml序列化 /// <summary> /// xml序列化 /// </summary> /// <param nam ...
- ubuntu 安装nginx, 出现 Unable to locate package
今天在初始化一台新的ubuntu 服务器时,敲上了 sudo apt-get install nginx 来安装nginx, 却发现提示: Reading package lists... Done ...
- Struts 2中如何解决中文乱码问题?
在配置文件中定义如下常量值配置: <constant name=”struts.i18n.encoding” value=”UTF-8”/> 注意:只能解决post请求的乱码问题,针对ge ...
- Jedis路由key的算法剥离
在Redis集群中,会有很多个分片,如果此时利用Jedis来操作此Redis集群,那么他会把数据路由到不到的分片上.而且如果动态的往集群中增加分片,也不会影响Jedis的功能.究竟是怎么做到的呢? 由 ...
- Abp.vNext 权限备注
Abp 内部是基于 asp.net core 基于 策略的 授权方式,每个权限为一个策略 权限分为: 1.定义权限(先定义权限组,后添加权限),每个模块都应该创建一个PermissionDefini ...
- 总结const、readonly、static三者的区别
const:静态常量,也称编译时常量(compile-time constants),属于类型级,通过类名直接访问,被所有对象共享! a.叫编译时常量的原因是它编译时会将其替换为所对应的值: b.静态 ...
- springboot学习小记
思维导图:https://www.edrawsoft.cn/viewer/public/s/72a06689197636 1.springboot是一个快速整合第三方框架,简化XML配置完全采用注解化 ...
- Excel文件数据导入到后台保存倒数据库
后台代码数据解析: 方法一: (简单点) import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermo ...