I am using hibernate 3 with spring. I have a domain object with a null int field that is causing the following exception when it is loaded from the database and the value of the property ansiProcessor is null in the database.
nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of mbs.test_newmodel.domainobjects.entities.Insurer.setAnsiProcessor
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of
If you are interested the full stack trace is below. The property I am trying to set is called ansiProcessor. I have gone through this over and over looking for a foolish mistake but I can't find one. It is very odd that only this property causes a problem. Thanks for your help.
Here is my class description.
Code:
<class name="mbs.test_newmodel.domainobjects.entities.Insurer" table="INSURER" lazy="false">
<id name="id" column="ID" type="int" unsaved-value="-1">
<generator class="identity"/>
</id>
<property name="name" column="NAME" not-null="true"/>
<property name="website" column="WEBSITE"/>
<property name="ansiPayerId" column="ANSI_PAYER_ID"/>
<property name="groupNumber" column="GROUP_NUMBER"/>
<property name="ansiProcessor" column="ANSI_PROCESSOR"/>
<property name="companyId" column="COMPANY_ID" not-null="true"/>
<many-to-one name="mailAddress" class="mbs.test_newmodel.domainobjects.entities.Address"
column="MAIL_ADDRESS_ID" cascade="all" />
<many-to-one name="workPhone" class="mbs.test_newmodel.domainobjects.entities.Phone"
column="WORK_PHONE_ID" cascade="all" />
<many-to-one name="fax" class="mbs.test_newmodel.domainobjects.entities.Phone"
column="FAX_ID" cascade="all" />
<many-to-one name="otherPhone" class="mbs.test_newmodel.domainobjects.entities.Phone"
column="OTHER_PHONE_ID" cascade="all" />
</class>
I tried the same with the not-null flag set to false and I got the same error. I have other classes that have null int fields that work fine. This class only seems to have a problem with this field, yet the groupNumber property does not cause a problem when it is null.
In my Insurer domain object i have these bean methods:
Code:
/**
* @return Returns the ansiProcessor.
*/
public int getAnsiProcessor()
{
return ansiProcessor;
}
/**
* @param ansiProcessor The ansiProcessor to set.
*/
public void setAnsiProcessor(int ansiProcessor)
{
this.ansiProcessor = ansiProcessor;
}
Also here is the sql statement I used to create the insurer table for hsqldb.
Code:
CREATE CACHED TABLE INSURER(
ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
NAME VARCHAR,
WEBSITE VARCHAR,
ANSI_PAYER_ID VARCHAR,
GROUP_NUMBER VARCHAR,
MAIL_ADDRESS_ID INTEGER,
OTHER_PHONE_ID INTEGER,
WORK_PHONE_ID INTEGER,
FAX_ID INTEGER,
COMPANY_ID INTEGER,
ANSI_PROCESSOR INTEGER,
CONSTRAINT FKY_INSURER_MAIL_ADDRESS FOREIGN KEY(MAIL_ADDRESS_ID) REFERENCES ADDRESS(ID),CONSTRAINT FKY_INSURER_OTHER_PHONE_ID FOREIGN KEY(OTHER_PHONE_ID) REFERENCES PHONE(ID),CONSTRAINT FKY_INSURER_WORK_PHONE_ID FOREIGN KEY(WORK_PHONE_ID) REFERENCES PHONE(ID),CONSTRAINT FKY_INSURER_FAX_ID FOREIGN KEY(FAX_ID) REFERENCES PHONE(ID),CONSTRAINT FKY_INSURER_COMPANY FOREIGN KEY(COMPANY_ID) REFERENCES COMPANY(ID),CONSTRAINT FKY_INSURER_ANSIPROCESSOR FOREIGN
KEY(ANSI_PROCESSOR) REFERENCES REFERENCE_PARAMETERS(ID))
Full stack trace:
Code:
org.springframework.orm.hibernate3.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of mbs.test_newmodel.domainobjects.entities.Insurer.setAnsiProcessor; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of mbs.test_newmodel.domainobjects.entities.Insurer.setAnsiProcessor
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of mbs.test_newmodel.domainobjects.entities.Insurer.setAnsiProcessor
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.loadEntity(Loader.java:1345)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:603)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:596)
at org.springframework.orm.hibernate3.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:438)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:315)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:432)
at org.springframework.orm.hibernate3.HibernateTemplate.load(HibernateTemplate.java:426)
at mbs.test_newmodel.dao.implementations.hibernate.enitities.InsurerDao.getInsurer(InsurerDao.java:27)
at mbs.test_newmodel.service.entities.DefaultEntityMgr.getInsurer(DefaultEntityMgr.java:248)
at mbs.test_newmodel.service.entities.DefaultEntityMgr.main(DefaultEntityMgr.java:423)
Caused by: net.sf.cglib.beans.BulkBeanException
at mbs.test_newmodel.domainobjects.entities.Insurer$$BulkBeanByCGLIB$$71aa7cfc.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
... 24 more
Caused by: java.lang.NullPointerException
... 26 more