Below I am trying to get the classMetadata off a lazy object that I initialized (using cglib reflection). Because exp is really just a Proxy, it is returning null. Is there a way to get the underlying instance once you initialized it?
The code is simplified example, but I want to use reflection to some stuff on the object. That's why I need the metadata.
Thanks,
Lou
Code:
public void testGetExposureType() throws DaoException, HibernateException {
ClmClaimExposure exp = expDao.find(new Long(948));
Hibernate.initialize(exp);
expDao.flushHibernateSession();
ClassMetadata classMetadata = sesFactory.getClassMetadata(exp.getClass());
assertNotNull(classMetadata);
}
Hibernate version: 2.1.6
Mapping documents:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.mitchell.services.technical.claim.dao.vo">
<class name="ClmClaimExposure" table="EXPOSURE" lazy="true">
<id
name="id"
type="java.lang.Long"
column="CLAIM_EXPOSURE_ID"
>
<generator class="sequence">
<param name="sequence">EXPOSURE_ID_SEQ</param>
</generator>
</id>
<version name="tcn" column="TCN" type="java.lang.Long" unsaved-value="null"/>
<property
column="CO_CD"
length="10"
name="coCd"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
NullPointerException
Name and version of the database you are using:
Oracle 9.2.1.0
Debug level Hibernate log excerpt: