Hi,
I'm facing a simple issue which I havent been able to resolve for long. I have defined a simple mapping from class to a existing table.
<hibernate-mapping package="com.nokia.ccpe.sam.model">
<class name="SoldtoVO"
table="SOLDTO"
>
<id name="soldtoId"
column="SOLDTOID">
<generator class="native" />
</id>
<property name="name"
column="NAME"
update="false"
insert="false"/>
<property name="cid"
column="CID"
update="false"
insert="false"/>
<property name="nodeId"
column="NODE_ID"
not-null="true"
update="false"
insert="false"/>
<property name="subAccountId"
column="SUBACCOUNTID"
not-null="true"
update="false"
insert="false"/>
<property name="dfPhoneActive"
column="DFPHONEACTIVE"
update="true"
insert="false"/>
<property name="cvActive"
column="CV_ACTIVE"
not-null="true"
update="true"
insert="false"/>
<property name="cvRowState"
column="CV_ROWSTATE"
update="true"
insert="false"/>
<property name="rowState"
column="ROWSTATE"
update="true"
insert="false"
type="integer"/>
<property name="cvRowStateTime"
column="CV_ROWSTATETIME"
update="true"
insert="false"/>
<property name="rowStateTime"
column="ROWSTATETIME"
update="true"
insert="false"
type="timestamp"/>
<property name="regionId"
column="PROJECT_ID"
update="false"
insert="false"/>
</class>
<query name="findsoldtobynodeid">
<![CDATA[
from SoldtoVO as soldto
where soldto.nodeId = ? ]]></query>
<query name="findsoldtobyprimarykey">
<![CDATA[
from SoldtoVO as soldto
where soldto.soldtoId = ? ]]></query>
<query name="findsoldundersubaccount">
<![CDATA[
from SoldtoVO as soldto
where soldto.subAccountId = ? ]]></query>
</hibernate-mapping>
When I try to run the findsoldtobyprimarykey query, I'm getting the following exception.
org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:876)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:867)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:863)
at com.nokia.ccpe.sam.dao.NodeTypeDaoImpl.getSoldtoVO(NodeTypeDaoImpl.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy2.getSoldtoVO(Unknown Source)
at com.nokia.ccpe.sam.dao.test.NodeTypeDaoTester.testGetSoldto(NodeTypeDaoTester.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: net.sf.cglib.beans.BulkBeanException
at com.nokia.ccpe.sam.model.SoldtoVO$$BulkBeanByCGLIB$$d862d87c.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 44 more
Caused by: java.lang.NullPointerException
... 46 more
I find that this exception only occurs when any field is nullable.
The rowstate variable is nullable in this case. Please see log below.
d2005-11-07 00:33:50,040 DEBUG [org.hibernate.SQL] - select soldtovo0_.SOLDTOID as SOLDTOID, soldtovo0_.NAME as NAME2_, soldtovo0_.CID as CID2_, soldtovo0_.NODE_ID as NODE4_2_, soldtovo0_.SUBACCOUNTID as SUBACCOU5_2_, soldtovo0_.DFPHONEACTIVE as DFPHONEA6_2_, soldtovo0_.CV_ACTIVE as CV7_2_, soldtovo0_.CV_ROWSTATE as CV8_2_, soldtovo0_.ROWSTATE as ROWSTATE2_, soldtovo0_.CV_ROWSTATETIME as CV10_2_, soldtovo0_.ROWSTATETIME as ROWSTAT11_2_, soldtovo0_.PROJECT_ID as PROJECT12_2_ from ccpeu1.SOLDTO soldtovo0_ where soldtovo0_.NODE_ID=?
dHibernate: select soldtovo0_.SOLDTOID as SOLDTOID, soldtovo0_.NAME as NAME2_, soldtovo0_.CID as CID2_, soldtovo0_.NODE_ID as NODE4_2_, soldtovo0_.SUBACCOUNTID as SUBACCOU5_2_, soldtovo0_.DFPHONEACTIVE as DFPHONEA6_2_, soldtovo0_.CV_ACTIVE as CV7_2_, soldtovo0_.CV_ROWSTATE as CV8_2_, soldtovo0_.ROWSTATE as ROWSTATE2_, soldtovo0_.CV_ROWSTATETIME as CV10_2_, soldtovo0_.ROWSTATETIME as ROWSTAT11_2_, soldtovo0_.PROJECT_ID as PROJECT12_2_ from ccpeu1.SOLDTO soldtovo0_ where soldtovo0_.NODE_ID=?
2005-11-07 00:33:50,040 DEBUG [org.hibernate.jdbc.AbstractBatcher] - preparing statement
d2005-11-07 00:34:32,824 DEBUG [org.hibernate.type.StringType] - binding '2759' to parameter: 1
d2005-11-07 00:35:15,859 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to open ResultSet (open ResultSets: 0, globally: 0)
d2005-11-07 00:35:15,859 DEBUG [org.hibernate.loader.Loader] - processing result set
d2005-11-07 00:35:15,869 DEBUG [org.hibernate.loader.Loader] - result set row: 0
d2005-11-07 00:35:15,869 DEBUG [org.hibernate.type.StringType] - returning 'OCEAM' as column: SOLDTOID
d2005-11-07 00:35:15,869 DEBUG [org.hibernate.loader.Loader] - result row: EntityKey[com.nokia.ccpe.sam.model.SoldtoVO#OCEAM]
d2005-11-07 00:35:15,869 DEBUG [org.hibernate.loader.Loader] - Initializing object from ResultSet: [com.nokia.ccpe.sam.model.SoldtoVO#OCEAM]
d2005-11-07 00:35:15,899 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] - Hydrating entity: [com.nokia.ccpe.sam.model.SoldtoVO#OCEAM]
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.StringType] - returning 'NOKIA FRANCE S.A.' as column: NAME2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.StringType] - returning null as column: CID2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.StringType] - returning '2759' as column: NODE4_2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.StringType] - returning '1318' as column: SUBACCOU5_2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.BooleanType] - returning 'false' as column: DFPHONEA6_2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.BooleanType] - returning 'true' as column: CV7_2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.IntegerType] - returning '0' as column: CV8_2_
d2005-11-07 00:35:15,909 DEBUG [org.hibernate.type.IntegerType] - returning null as column: ROWSTATE2_
d2005-11-07 00:35:15,929 DEBUG [org.hibernate.type.TimestampType] - returning '2005-11-04 14:56:49' as column: CV10_2_
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.type.TimestampType] - returning null as column: ROWSTAT11_2_
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.type.IntegerType] - returning '2' as column: PROJECT12_2_
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.loader.Loader] - done processing result set (1 rows)
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to close ResultSet (open ResultSets: 1, globally: 1)
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.jdbc.AbstractBatcher] - closing statement
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.loader.Loader] - total objects hydrated: 1
d2005-11-07 00:35:15,939 DEBUG [org.hibernate.engine.TwoPhaseLoad] - resolving associations for [com.nokia.ccpe.sam.model.SoldtoVO#OCEAM]
d2005-11-07 00:35:15,949 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] - Not closing pre-bound Hibernate Session after HibernateTemplate
d2005-11-07 00:35:15,949 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - Applying rules to determine whether transaction should rollback on org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState
d2005-11-07 00:35:15,949 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - Winning rollback rule is: null
d2005-11-07 00:35:15,949 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] - No relevant rollback rule found: applying superclass default
d2005-11-07 00:35:15,949 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] - Invoking rollback for transaction on com.nokia.ccpe.sam.dao.inf.NodeTypeDaoInf.getSoldtoVO due to throwable [org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.nokia.ccpe.sam.model.SoldtoVO.setRowState]
d2005-11-07 00:35:15,949 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] - Triggering beforeCompletion synchronization
d2005-11-07 00:35:15,949 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] - Initiating transaction rollback
d2005-11-07 00:35:15,949 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] - Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@f62eba]
d2005-11-07 00:35:15,949 DEBUG [org.hibernate.transaction.JDBCTransaction] - rollback
Can someone please HELP!!!!?
Thanks
Dheepak
|