错误!错误!错误!

[11-07 10:55:28] [http-bio-8080-exec-2] [ERROR][com.shinowit.dao.BaseDAO-179]-Null value was assigned to a property of primitive type setter of com.shinowit.entity.TAuOperInfo.id
org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.shinowit.entity.TAuOperInfo.id

数据库里一个字段值为NULL,进行对象持久化关联时,企图给对象的这个属性赋值为空,而对象实例的这个属性不能为空值,所以出现错误。【int型,不能为空】

之前说过的,int型的东西不能为空。

 解决方法:将该字段在类中的类型定义为Integer。

Integer   code和int   code的区别:
Integer是对象        code   =   null;   对象可以为空.   
int   是普通类型        不可能   =   null.       
根据在数据库里,code是可以空的,故应该映射成Integer类型的。 而且hibernate中要用包装类java.long.Integer,不要用基本类型Integer.

equals 和==的区别

http://new-fighter.iteye.com/blog/1634786

原文地址:https://www.cnblogs.com/chfg/p/4080826.html