码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2017-04-04 17:40:15      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:tran   原因   dea   mic   with   str   public   and   实体   

日志:
[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






















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

标签:tran   原因   dea   mic   with   str   public   and   实体   

原文地址:http://www.cnblogs.com/duenboa/p/6665354.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!