今日在开发时遇到一个比较奇怪的问题,保存时报这个异常:

  1. org.hibernate.AssertionFailure: null id in com.aa.TShoucang

null id,这个是什么回事呢?数据库是自动增长了,hibernate映射文件也一切正常的了,看了后台也打印出了insert into ....这个的语句了,但为什么就是插入不成功呢?

本着知之为知之,不知google之的精神,google了一下,都是说数据库与映射文件不对应,数据库设置了不为null,但hibernate里的映身文件设置了为null等等的.

发现都不是这个的问题,后来直接将打印出来的sql语句发送到数据库里执行一下,也是报一样的错,也就是说与hibernte没关系了.如以下这一句:

  1. insert into t_shoucang (url, describe, objic, userid, createuserid, createusername, createtime, updatetime, id) values ('aa', 'bb', 'cc', 'dd', 'ee', 'ff', '2010-01-01', '2010-01-01', 'abcd123');

发现describe这个字段变成了蓝色,是关键字,加多一个s后,再运行,OK了.

所以总结得出,null id这个问题时,有可能是字段里用到了数据库的关键字了.

今日又再出现这个问题了,并不是数据库关键字的原因了,如果数据库里设置了某个字段值不为null,而你保存的时候就设置了为null,也会报这个异常的。郁闷....

org.hibernate.AssertionFailure: null id in xxx.xx.xx的问题的更多相关文章

  1. org.hibernate.AssertionFailure: null id in xxx entry (don't flush the Session after an exception occurs)

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

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

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

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

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

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

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

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

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

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

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

  9. org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.trs.om.bean.User.retryCount

    六月 29, 2019 5:42:45 下午 org.apache.catalina.core.AprLifecycleListener init信息: The APR based Apache To ...

随机推荐

  1. FIN vs RST in TCP connections different

    question: The way I understand this, there are 2 ways to close TCP connection: send FIN flag send RS ...

  2. kafka的安装 (单机)

    https://blog.csdn.net/q282176713/article/details/81112988

  3. delphi中Application.MessageBox函数用法详解

    delphi中Application.MessageBox函数用法详解 Application.MessageBox是TApplication的成员函数,声明如下:functionTApplicati ...

  4. 让WordPress支持google AMP

    1.关于AMP 在移动互联网的时代,尽管网站响应式设计可以满足多屏(pc.手机.ipad等)浏览,但google在2015年10月推出了更快移动页面访问速度的技术-Accelerated Mobile ...

  5. 小米造最强超分辨率算法 | Fast, Accurate and Lightweight Super-Resolution with Neural Architecture Search

    本篇是基于 NAS 的图像超分辨率的文章,知名学术性自媒体 Paperweekly 在该文公布后迅速跟进,发表分析称「属于目前很火的 AutoML / Neural Architecture Sear ...

  6. Centos下安装Docker集群管理工具Shipyard

    一. Docker Shipyard是什么 ? shipyard是一个开源的docker管理平台,其特性主要包括: 支持镜像管理.容器管理. 支持控制台命令 容器资源消耗监控 支持集群swarm,可以 ...

  7. mac“打不开身份不明的开发者”

    在mac安装软件发现这样的提示 解决方法: 打开系统偏好设置-->安全与隐私-->通用-->选择任何来源 不能选择的话点击按钮锁即可编辑 没有“任何来源”选项(比如我的mac) 打开 ...

  8. C# WPF 文件复制,相对路径

    /// <summary> /// 下载/复制 /// </summary> /// <param name="sender"></par ...

  9. (转)使用Flexible实现手淘H5页面的终端适配

    原文链接 曾几何时为了兼容IE低版本浏览器而头痛,以为到Mobile时代可以跟这些麻烦说拜拜.可没想到到了移动时代,为了处理各终端的适配而乱了手脚.对于混迹各社区的偶,时常发现大家拿手机淘宝的H5页面 ...

  10. 微信小程序开发踩坑日记

    2017.12.29  踩坑记录 引用图片名称不要使用中文,尽量使用中文命名,IDE中图片显示无异样,手机上图片可能出现不显示的情况. 2018.1.5  踩坑记录 微信小程序设置元素满屏,横向直接w ...