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

原文:http://blog.csdn.net/kevinzhangfei/article/details/6995316

总结:在Java中使用大写的数据类型。

在action请求数据的过程中报出"Null value was assigned to a property of primitive type setter of"错误,搜索之后发现是因为数据库里相应的字段为NULL。

例如:

Java代码

<!--Hibernate映射文件中的字段-->

<property name="printTime" type="long"><column name="print_time"/></property>

[java] view plain copy

print?

  1. <!--Hibernate映射文件中的字段-->
  2. <property name="printTime" type="long"><column name="print_time"/></property>

其中的类型为hibernate类型,在生成的类中,printTime字段为long类型,为基本类型,不能为NULL.
解决方法:
    第一种:数据库字段不设置为空;
    第二种:手动修改映射文件,printTime使用Java类型Long,即type="java.lang.Long",Book类中的字段也要改为Long。同理,int为Integer.
    第三种:在反向工程时使用Java类型,而不是hibernate类型。

时间: 2024-08-12 16:39:33

Null value was assigned to a property of primitive type setter of"原因及解决方法的相关文章

[转]Null value was assigned to a property of primitive type setter of&quot;原因及解决方法

原文地址:http://blog.csdn.net/kevinzhangfei/article/details/6995316 在action请求数据的过程中报出"Null value was assigned to a property of primitive type setter of"错误,搜索之后发现是因为数据库里相应的字段为NULL. 例如: Java代码 <!--Hibernate映射文件中的字段--> <property name="pri

null value was assigned to a property of primitive type setter of原因解决方法

原理如下: Integer与int的区别: Integer是对象.     因此可以为null(对象可以为空.),即property   =   null;      int   是普通类型, 不可以为null. 数据库中的property是空的,可以映射额外integer类型,但是不能映射为int类型,如果误在实体中将property定义成了int类型,就有可能会出这种错误. 解决方法: 把数据库中的数据删除,重新录入. 或者 将实体中对应property修改为integer类型.

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

解决办法: bean里的int 类型替换成 Integer .hbm.xml  改为java.lang.Integer Null value was assigned to a property of primitive type setter of,布布扣,bubuko.com

[hibernate]org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter

org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.wa.dataprocess.query.model.AcrossDeptApply 包装类和基本数据类型的区别, 包装类默认为null,基本类型为0. public class AcrossDeptApply implements Serializable private Str

org.hibernate.PropertyAccessException:Null value was assigned to a property of primitive type setter

在项目开发中遇到下面的异常:org.hibernate.PropertyAccessException:Null value was assigned to a property of primitive type setter ofcom.atguigu.surveypark.model.Page.orderno 这个异常的解释是:      Null值被分配给了设置为基本类型的Page类里的orderno属性.也就是说Null是不能分配给基本数据类型的.解决办法:手动给数据库中是Null值的

Null value was assigned to a property of primitive type setter

org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property of primitive type setter of com.eshore.ismp.order.entity.HandSiOrder.siSize; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a

Null value was assigned to a property of primitive type setter of cn.itcast.oa.domain.Forum.topicCount

[引用http://m.blog.csdn.net/blog/u013998070/41087351] Null value was assigned to a property of primitive type setter of cn.itcast.oa.domain.Forum.topicCount 2014-11-13阅读376 评论0 最近做一个OA项目,其中有一个论坛管理的版块,起初在实体类Forum只有几个字段,在数据库中也有对应的数据,在页面显示时,完全没有任何问题:但是后来在

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

前段时间,写了个方法,测试的时候报错了.Null value was assigned to a property of primitive type setter of.百度了一下,发现是hibernate的问题.sqlserver数据库中,字段类型为float,类中用float类型,那么,hibernate不允许数据库中的这个字段值为null. 解决方法:类中字段类型改为 Float 类型--float的封装类. 原文地址:https://www.cnblogs.com/wensy/p/88

org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of 异常

在开发项目的过程中,发现如下异常: 原因是updateType字段为int类型,不能接收null,而在数据库中对应的字段为null,解决方法:将updateType字段类型改为Integer.