我上周遇到一个问题
hibernate native自增长设置null id 异常,原帖子地址http://topic.csdn.net/u/20110406/09/1a27c751-d817-4cdb-a7fd-0fda09582309.html,
异常信息为
Caused by: org.hibernate.exception.DataException: could not insert:
Caused by: com.ibm.db2.jcc.a.wm: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=3.51.90
org.hibernate.AssertionFailure: null id in entry (don’t flush the Session after an exception occurs)
java.lang.reflect.InvocationTargetException
Caused by: org.hibernate.AssertionFailure: null id in entry
(don’t flush the Session after an exception occurs)
上次我以为是主键生成为空,但是试了native和identity都不行,后来测试发现是由于有个字段长度不足,但是hibernate报出的这个提示信息不对,不方便定位,我把数据库字段长度设置长点之后问题就解决了。
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/13623.html