建议: 使用Hibernate 时,数据库建表是int , number 类型的数据能给默认值的给默认值。
Hibernate
exception :
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info)
因为查询结果中包含null项,而我的model中diesVolume 属性是int类型的,而该字段在数据库中正好是空的(null).所以抛出异常。
解决方法:
1、将数据库的该字段的值默认为0 ----最最恶心的解决方法,不幸被我采用了。
2、对于一些数字项包含null,model中定义该项时必须使用wrapper类型,而不能是primitive类型,例如使用Integer等,而不能是int,否则会抛出exception! --- 不错的解决方法,不过有的时候用int要方便些。
3、我猜想的解决方法,自己没有实验:model定义的时候设定初始值
private int diesVolume = 0;