Hibernate version:
3.2
Mapping documents:
Code:
<class name="A" table="A" schema="A">
<id name="aKey" column="A_KEY" type="integer">
<generator class="assigned" />
</id>
<one-to-one name="bA" property-ref="aA" entity-name="BA" constrained="true" fetch="select" lazy="proxy" />
</class>
<class name="A" table="A" schema="B" entity-name="BA" lazy="true">
<id name="aKey" column="A_KEY" type="integer">
<generator class="assigned" />
</id>
<many-to-one name="aA" column="A_A_KEY" class="com.xxx.A" />
</class>
Name and version of the database you are using:
DB2
Problem
I need my one-to-one association to be lazy loading. Especially as the two tables are in different schema and queries result in table locks. I followed the directions here (
http://www.hibernate.org/117.html#A18) as you can see from my mapping but any instance of A.A that is returned by a query results in a select statement for the associated B.A instance being executed. For me, this can generate many more queries depending on the size of the result set returned (100 instances of A.A isn't unusual resulting in 100 extra queries).
Is there a way to make this truly lazy loading?
Thanks in advanced