Hibernate. Propertyaccessexception:null value is assigned to a property of primitive type

Source: Internet
Author: User
Tags aop log log wrapper

Log:
[Warn-2016/07/26/18/:45/:52] Processengineserviceimpl. (257)-Approval process log log--submitprocess method: Author userid:3333333349,taskid:245959,procinstid:null,wfinstaceid:16583386853, Current time: Tue Jul 18:45:52 CST 2016[error-2016/07/26/18/:45/:52]projectrepaycontroller. (129)-Approval process Error! Null value is assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort; Nested exception is Org.hibernate.PropertyAccessException:Null value were assigned to a property of primitive type setter Of Com.boa.workflow.model.domain.WfFlowLinkInst.nextSortorg.springframework.orm.hibernate3.HibernateSystemException  : Null value is assigned to a property of primitive type setter of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort;  Nested exception is Org.hibernate.PropertyAccessException:Null value were assigned to a property of primitive type setter of Com.boa.workflow.model.domain.WfFlowLinkInst.nextSort at Org.springframework.orm.hibernate3.SessionFactoryUtil S.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. $Proxy 3630.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 $ $eff 4E582.DEALWF (<generated>) at Com.boa.workflow.service.ProcessProxyServiceImpl.approvalWorkFlow (processproxyserviceimpl.java:117) at com.boa.workflow.service.processproxyserviceimpl$ $FastClassByCGLIB $ $dc 3563e8.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 $ $d 84bd278.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.DelegatingM Ethodaccessorimpl.invoke (delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (Method.java : 606) caused by:org.hibernate.PropertyAccessException:Null value is assigned to a property of primitive type sett Er of com.boa.workflow.model.domain.WfFlowLinkInst.nextSort at Org.hibernate.property.directpropertyaccessor$direc Tsetter.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.L Oader.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.J ava:2512) at Org.hibernate.loader.Loader.listIgnoreQueryCache (loader.java:2342) at Org.hibernate.loader.Load Er.list (loader.java:2337) at Org.hibernate.loader.custom.CustomLoader.list (customloader.java:338) at Org.hib Ernate.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) ... More
Analysis Code:
Entity class:
@Entity
@Table "table_name")
Auditauto {

@Column "Next_sort")
Nextsort;
   Getter setter .....  
}
database This property corresponds to the field:Next_sort tinyint (4) NULL Next approval node ordinal


Reason:        The database field is an integer, and the corresponding field in the entity class is int, and hibernate cannot map it to the base type int if the value in the database to which it is queried is null.
Workaround:    sets the data type of the entity class to the wrapper class of the base type. Integer, try to avoid using the base type for entity class attributes!!!! Wrapper classes can solve some null pointer problems.
   @Column "Next_sort")  
       Nextsort;




















From for notes (Wiz)

Hibernate. Propertyaccessexception:null value is assigned to a property of primitive type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.