AssertionFailure: null id in xxx entry (don't flush the Session after an exception occurs
org.hibernate.AssertionFailure entry null id in entry (don't flush the Session after an exception occurs)异常
这个错误看上去是因为id为空了。
解决: 我们没有为数据中的非空字段设置值!
其实还有一种原因:
那就是方法没有添加事务。
我只对service进行了事务拦截,而没有对dao进行事务aop
在action中直接调用了dao,就会出现数据库正常插入了数据,但报出了上面的错误。
这是因为在插入数据库时,数据库有自增ID的主键策略,而hibernate在flush的时候,发现model中的id为空所致。
为什么会为空,就是没有经过事务处理,hibernate主键策略没有运行。
但为什么能正常插入了数据库,研究中。。。