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

  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. 10 Skills Every SharePoint Developer Needs

    10 Skills Every SharePoint Developer Needs(原文) This blog post guides you through the essential skill ...

  2. Delphi StringGrid控件的用法

    Delphi StringGrid控件 组件名称:StringGrid         ●固定行及固定列:  StringGrid.FixedCols:=固定行之数;  StringGrid.Fixe ...

  3. CS229 6.12 Neurons Networks from self-taught learning to deep network

    self-taught learning 在特征提取方面完全是用的无监督的方法,对于有标记的数据,可以结合有监督学习来对上述方法得到的参数进行微调,从而得到一个更加准确的参数a. 在self-taug ...

  4. Codeforces Round #493 (Div. 1)

    A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...

  5. 【Jmeter自学】JMeter的安装(一)

    ==================================================================================================== ...

  6. QT编写TCP的问题

    ---->>>TCP编写实战的小项目 TCP套接字:主机(IP+端口) 和 服务器(IP+端口) 进行通讯,需要中间的一个锁套进行  啮合,这个锁套就是套接字的作用. 其中套接字的使 ...

  7. [UGUI]图文混排(四):插入图片

    参考链接: http://www.cnblogs.com/leoin2012/p/7162099.html 0.图片标签和图片类 标签格式:<icon name=*** w=1 h=1 n=** ...

  8. python 日期创建dir

  9. 关于thinkphp5被入侵后的一些思考

    最近一段时间thinkphp5爆出漏洞  request.php中的请求过滤不严 是得web端 可以直接写入一个文件到服务器上 进而可得webshell权限 我的一个客户 就是这样被入侵了   刚开始 ...

  10. Pig latin基础

    pig的两种运行模式,local模式,mapreduce模式 local模式下,pig只能访问本地一台:在mapreduce模式下,pig可以访问一个hadoop集群和hdfs的安装位置.这时,pig ...