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

日志:
[WARN-2016/07/26/18/:45/:52]ProcessEngineServiceImpl.(257) - 审批流程log日志——submitProcess方法:提交人userId:3333333349,TaskId:245959,ProcInstId:null,WfInstaceId:16583386853,当前时间:Tue Jul 26 18:45:52 CST 2016
[ERROR-2016/07/26/18/:45/:52]ProjectRepayController.(129) - 审批流程出错!Null value was assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort
org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690)
        at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:106)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
        at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
        at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:105)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at com.sun.proxy.$Proxy3630.findByWfInstanceIdAndUserid(Unknown Source)
        at com.boa.workflow.manager.impl.WfCommentManagerImpl.flowRuntimeToComment(WfCommentManagerImpl.java:82)
        at com.boa.workflow.manager.impl.WfCommentManagerImpl.insertComment(WfCommentManagerImpl.java:52)
        at com.boa.workflow.service.ProcessEngineServiceImpl.submitProcess(ProcessEngineServiceImpl.java:277)
        at com.boa.workflow.service.ProcessEngineServiceImpl.completeTask(ProcessEngineServiceImpl.java:223)
        at com.boa.workflow.service.ProcessEngineServiceImpl.dealWf(ProcessEngineServiceImpl.java:106)
        at com.boa.workflow.service.ProcessEngineServiceImpl$$FastClassByCGLIB$$3de96632.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:627)
        at com.boa.workflow.service.ProcessEngineServiceImpl$$EnhancerByCGLIB$$eff4e582.dealWf(<generated>)
        at com.boa.workflow.service.ProcessProxyServiceImpl.approvalWorkFlow(ProcessProxyServiceImpl.java:117)
        at com.boa.workflow.service.ProcessProxyServiceImpl$$FastClassByCGLIB$$dc3563e8.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
        at com.boa.workflow.service.ProcessProxyServiceImpl$$EnhancerByCGLIB$$d84bd278.approvalWorkFlow(<generated>)
        at com.boa.weixin.controller.costmanager.expenses.ProjectRepayController.approvalProjectRepayApply(ProjectRepayController.java:122)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
Caused by: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort
        at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:143)
        at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:710)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:379)
        at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4509)
        at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:186)
        at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
        at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1108)
        at org.hibernate.loader.Loader.processResultSet(Loader.java:964)
        at org.hibernate.loader.Loader.doQuery(Loader.java:911)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
        at org.hibernate.loader.Loader.doList(Loader.java:2526)
        at org.hibernate.loader.Loader.doList(Loader.java:2512)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2342)
        at org.hibernate.loader.Loader.list(Loader.java:2337)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
        at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1827)
        at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:231)
        at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:157)
        at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:287)
        ... 71 more

分析代码: 

实体类:

@Entity@Table(name = "table_name")public class WfFlowLinkInst extends AuditAuto {

@Column(name = "next_sort")   private int nextSort;   
   //getter setter  .....

}

数据库该属性对应字段:

next_sort   tinyint(4)   NULL   下一个审批节点序号


原因: 

数据库字段为整型,  实体类中对应字段为int,  如果数据库中该字段查询到的值为null, 则hibernate无法将其映射为基本类型int.

解决办法:

将实体类的数据类型设置为基本类型的包装类.  Integer  , 尽量避免实体类属性使用基本类型!!!!包装类可以解决部分空指针问题.

        @Column(name = "next_sort")
       private Integer nextSort; 

来自为知笔记(Wiz)

时间: 2024-10-13 02:20:23

hibernate.PropertyAccessException: Null value was assigned to a property of primitive type的相关文章

[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 sette

org.hibernate.PropertyAccessException: Null value was assigned to a property <property column="sex"  name="sex"  type="java.lang.Boolean"/> JavaBean修改:private Boolean sex; 原因:数据库字段值为NULL,int 类型不能赋值为NULL,只能为0,但有些实际应用中,如学

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值的

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

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

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&quot;原因及解决方法

原文: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映射文件中的字段--> <prope

[转]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。

前段时间,写了个方法,测试的时候报错了.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