I set lazy="false" on the many-to-one element yet after I close the session I a getting a proxy exception. any ideas?
Thanks for any suggestions
J
Hibernate version:
3.1
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.volant.vini.model.VsiCounty" table="vsi_county" catalog="vini">
<composite-id name="id" class="com.volant.vini.model.VsiCountyId">
<key-property name="countyCode" type="string">
<column name="COUNTY_CODE" length="3" />
</key-property>
<key-property name="stateCode" type="string">
<column name="STATE_CODE" length="2" />
</key-property>
</composite-id>
<many-to-one name="vsiState" class="com.volant.vini.model.VsiState" lazy="false" update="false" insert="false">
<column name="STATE_CODE" length="2" not-null="true" />
</many-to-one>
<property name="countyName" type="string">
<column name="COUNTY_NAME" length="50" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
VsiCounty county = (VsiCounty) ViniSessionFactory.currentSession()
.load(VsiCounty.class, new VsiCountyId("42", "001"));
ViniSessionFactory.closeSession();
assertNotNull("state is null", county.getVsiState());
Full stack trace of any exception that occurs:Code:
ERROR [main] (LazyInitializationException.java:19) - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:54)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:85)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:131)
at com.volant.vini.model.VsiCounty$$EnhancerByCGLIB$$593f1e55.getVsiState(<generated>)
at com.volant.vini.test.db.TestViniDAO.testNoneLazyState(TestViniDAO.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Name and version of the database you are using:
Oracle 10 g
The generated SQL (show_sql=true):
na
Debug level Hibernate log excerpt:
na