Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.01
Mapping documents:
Code:
<hibernate-mapping package="com.llic.calc.label">
<class name="Label" table="Label">
<id name="id" column="labelid" type="java.lang.Long">
<generator class="native" />
</id>
<property name="name" column="name" type="string" unique="true"/>
<many-to-one name="equation" class="com.llic.calc.variable.EquationVariable" lazy="false"/>
<!-- map of database labels -->
<map name="dbVar" lazy="false">
<key column="labelid"/>
<map-key type="java.lang.Long" column="dbvarid"/>
<element type="java.lang.Long" column="rowId"/>
</map>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():String hql = "from " + getBusinessClass() + " as label where label.name = :name";
List results = getHibernateTemplate().findByNamedParam(hql, "name", name);
return (Label) getFirstResult(results);
Full stack trace of any exception that occurs:Code:
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.llic.calc.variable.EquationVariable$$EnhancerByCGLIB$$95da3f81.getVariables(<generated>)
at com.llic.calc.LabelPreparer.prepareEquation(LabelPreparer.java:48)
at com.llic.calc.LabelPreparer.applyLabel(LabelPreparer.java:38)
at com.llic.calc.EquationFactory.getLabeledEquation(EquationFactory.java:224)
at com.llic.calc.LabelingTest.testLabelAdd(LabelingTest.java:81)
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:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Name and version of the database you are using:MySQL 4.0
The generated SQL (show_sql=true):Code:
select dbvar0_.labelid as labelid__, dbvar0_.rowId as rowId__, dbvar0_.dbvarid as dbvarid__ from ides_dbVar dbvar0_ where dbvar0_.labelid=?
Hibernate is lazy loading the map. I explicity set lazy="false" in the mapping, since I do not want to lazy load the map. The session is closed when the map is utilized in our logic, and we will always use all of the entries. Should I report this as a bug in Jira, or did I simply overlook something obvious?
[/code]