网上找了很久,发现造成原因有很多种,后来终于发现了端倪;看提示是发生了异常,查看业务代码,发现有这个逻辑:先插入记录,如果有唯一键约束异常(并发造成),catch时查询已存在的记录,查询的时候就报了此错误。

  原因:异常后,再次查询的时候触发了autoFlush,先前保存失败的记录会再次保存,导致抛出如标题所述异常。

  解决方法:数据库是mysql,改为采用 insert ignore into语句进行插入

  当然有很多处理方法,就不赘述了

org.hibernate.AssertionFailure: null id in xxx entry (don't flush the Session after an exception occurs)的更多相关文章

  1. 报错: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 ...

  2. 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) 遇到这个异常实属不小心所致,最初看到异出的错误信息时我误认为是 ...

  3. org.hibernate.AssertionFailure: null id in xxx.xx.xx的问题

    今日在开发时遇到一个比较奇怪的问题,保存时报这个异常: org.hibernate.AssertionFailure: null id in com.aa.TShoucang null id,这个是什 ...

  4. null id in entry (don't flush the Session after an exception occurs) 解决方法

    最近在学习基于ssh的注解的系统,然后在实现往数据库增加记录时可以增加第一个,第二个就报错,在网上查了很多资料,大多都是 该异常信息是在提示我们没有为数据中的非空字段设置值. 然后就一直没有明白 明明 ...

  5. 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 ...

  6. org.hibernate.AssertionFailure: null id don't flus

    我的是字段编码和数据库不匹配,是爬的微博数据

  7. org.hibernate.AssertionFailure: null id 错误

    对象属性有Blob类型: 而Blob需在输入流中读取: InputStream in = new FileInputStream(url.getFile()); Blob bookPic = lobH ...

  8. null id in com.rocky.** entry 错误处理

    1. 概述 使用hibernate往mysql数据库插入记录出错如下 10:37:57,364 ERROR [AssertionFailure] an assertion failure occure ...

  9. 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属性(数据库中有此列) ...

随机推荐

  1. Bubble sort of sorting algorithm

    Bubble sort,It's a relatively basic algorithm.The core implementation ideas are as follows: 1.Define ...

  2. 如何在Rails6内通过Webpacker使用JavaScript; flatpicker日期时间组件选择器

    如何在Rails6内通过Webpacker使用JavaScript; Rails6默认不再使用asset pipeline,改用Webpacker. 文件结构变化: 配置文件: webpacker.y ...

  3. java第四次上机

    package bbb;public class Person { private String name; private int age; public Person(){ } public Pe ...

  4. D - Mayor's posters(线段树+离散化)

    题目: The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campai ...

  5. Vue的父子组件间通信及借助$emit和$on解除父子级通信的耦合度高的问题

    1.父子级间通信,父类找子类非常容易,直接在子组件上加一个ref,父组件直接通过this.$refs操作子组件的数据和方法    父 这边子组件中 就完成了父 => 子组件通信 2. 子 =&g ...

  6. 前后端token机制 识别用户登录信息

    Token,就是令牌,最大的特点就是随机性,不可预测.一般黑客或软件无法猜测出来. 那么,Token有什么作用?又是什么原理呢? Token一般用在两个地方: 1)防止表单重复提交. 2)anti c ...

  7. js统一设置富文本中的图片宽度

    var txt = layedit.getContent(ieditor);//获取编辑器内的文本var regex = new RegExp('<img', 'gi');txt = txt.r ...

  8. LARS 最小角回归算法简介

    最近开始看Elements of Statistical Learning, 今天的内容是线性模型(第三章..这本书东西非常多,不知道何年何月才能读完了),主要是在看变量选择.感觉变量选择这一块领域非 ...

  9. Vue-devtools 安装浏览器调试

    工欲善其事,必先利其器. 本文主要讲解Vue-devtools的安装和使用 安装方法有两个: 方法一:(前提条件需要FQ,省事省力省心方便快速) FQ =>谷歌商店 =>搜索 =>V ...

  10. MySQL改密码

    必须先修改my.cnf 添加 skip-grant-tables   然后  执行  update mysql.user set authentication_string=password('123 ...