首页 > 代码库 > Null value was assigned to a property of primitive type setter of

Null value was assigned to a property of primitive type setter of

Exception:
org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.vtradex.swms.server.model.receiving.ASN.coolingFee

 

原因是因为数据库为null,是新增的字段

 

<!--降温费  --> 
  <property name="coolingFee" type="double" column="COOLING_FEE"/>

 

解决方法有两个:

   1. 往数据库添加默认值,这里可以手动添加:

        update wms_asn a set a.coolingFee = 0.0

   2.修改映射文件,把double类型改成相应包装类

<!--降温费  --> 
  <property name="coolingFee" type="java.lang.Double" column="COOLING_FEE"/>

 

原则上应该做对象设计,不做数据库设计,设计类的时候,类的属性都应该设为java基本类型对应的包装类,防止查询数据时报错。

Null value was assigned to a property of primitive type setter of