In our (example-)mapping (Child.hbm.xml) we have a many-to-one reference to an other object (Parent) using the property-ref attribute. The problem is, that the referenced object is loaded with it.
In our business application we have a huge chain of many-to-one references between the tables using the "property-ref" attribute, which leads to "OutOfMemory" exception when we are trying to load just one object, since lazy-loading is not fully implemented for this case.
What we would urgently need is lazy loading for many-to-one relations with "property-ref" attributes.
Is there a chance to have this functionality in the final 3.1 version?
Hibernate version: 3.1b2
Mapping documents:
<!-- Child.hbm.xml -->
<hibernate-mapping>
<class name="nts.infrastructure.dataprovider.Child" table="CHILD">
<id name="gidc" column="GIDC">
<generator class="increment" />
</id>
<property name="name" column="NAME" />
<property name="xc" column="XC" />
<property name="yc" column="YC" />
<many-to-one name="parent" class="nts.infrastructure.dataprovider.Parent" unique="true" property-ref="parent_key" insert="false" update="false" lazy="proxy">
<column name="xc"/>
<column name="yc"/>
</many-to-one>
</class>
</hibernate-mapping>
<!-- Parent.hbm.xml -->
<hibernate-mapping>
<class name="nts.infrastructure.dataprovider.Parent" table="PARENT">
<id name="gidp" column="GIDP">
<generator class="increment" />
</id>
<property name="name" column="NAME" />
<property name="xp" column="XP" />
<property name="yp" column="YP" />
<properties name="parent_key" unique="true" update="false">
<property name="xp" column="XP" insert="false" update = "false"/>
<property name="yp" column="YP" insert="false" update = "false"/>
</properties>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Query q = session.createQuery("from Child");
List res = q.list();
for (Iterator it = res.iterator(); it.hasNext();) {
Child c = (Child) it.next();
Parent parent = c.getParent();
}
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|