org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.xugao.bean.MemberLevel.memberpointrate

由于数据不合法的原因,好几次遇到:

org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.xugao.bean.MemberLevel.memberpointrate

的异常,很有必要把它记录下来,以免忘记,

当遇到异常的时候一般都是 表中字段有空的情况,

例如:Membenlevel 表, memberpointrate这个字段的值为空

org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.xugao.bean.MemberLevel.memberpointrate

如果,对应实体类Membenlevel 中

private double memberpointrate;

则会报上面的异常:

修改方法,

private Double memberpointrate;

原因很简单,在java中不能对double,int, 等基本数据类型赋nul值   只能对封装类赋null值

上一篇:这可能是目前最全的!java经典书籍排行豆瓣


下一篇:Null value was assigned to a property of primitive type setter of"原因及解决方法