org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property [包名.class.属性名]

org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property [包名.class.属性名] of primitive type setter of com.udreamtech.admin.system.domain.Staff.acc_per; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property [包名.class.属性名] of primitive type setter of com.udreamtech.admin.system.domain.Staff.acc_per

最近spring-boot+JPA  ing……

错误如上,问题:属性名和数据库内的不一致

                  解决:找对应字段的实体类和数据库的字段是否一致。

然后我感觉没毛病,抓了半天脑袋,发现确实是我的问题。肥宅大哭!!!

org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property [包名.class.属性名]_第1张图片

因为,数据库字段是double。我的staff如下

	//公积金比例
	private double acc_per;

乍一看感觉没问题!!!

但是,double是基本数据类型,不是包装类!!!没有自带许多方法所以,正确的应该如下!

	//公积金比例
	private Double acc_per;

类似的还有 Float和float,Integer 和int   大家注意。

 

你可能感兴趣的:(Java后端开发)