Hello all,
Before I get started I should probably mention that I am well aware of
http://www.hibernate.org/162.html, the hibernate manual and I have spent the last two days reading this forum.
As the subject suggests, I am unable to get lazy loading from a one-to-one mapping.
I have two relatively simple clases in a one-to-one relationship with each other. Everything seems to be set up fine:
Now for the details:
One of the classes (BlobItemPayload) is tagged as lazy and has its own native generator.
The other class (BlobItem) has a foreign id, linked to the one-to-one relationship between the two classes. The relationship on this end is constrained.
The entire process of creating and reading objects works flawlessly (no abnormal messages in the log) but whenever I call
.list and get a list of
BlobItem objects, hibernate goes ahead and does a select for each of them in order to retrieve the associated
BlobItemPayload.
I am using the following:
MS SQL Server 2000 database with the latest (SP2) JDBC drivers from Microsoft[/list
[list]Hibernate 2.1.4
Any ideas/hints would be greatly appreciated.
Best regards,
diz
The actual mapping is as follows:
Code:
<hibernate-mapping>
<class name="com.aspectcapital.util.timeseries.hibernate.BlobItemPayload"
table="BlobData" dynamic-update="false"
dynamic-insert="false" select-before-update="false"
lazy="true">
<id name="payload_id" column="payload_id" type="long" >
<generator class="native"> </generator>
</id>
<property .../SNIP/... />
<one-to-one
name="payload_info"
class="com.aspectcapital.util.timeseries.hibernate.BlobItem"
cascade="none" outer-join="false" constrained="false" />
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="com.aspectcapital.util.timeseries.hibernate.BlobItem"
table="BlobItems" dynamic-update="false" dynamic-insert="false" select-before-update="false" lazy="true" >
<id name="item_id" column="item_id" type="long">
<generator class="foreign">
<param name="property">payload</param>
</generator>
</id>
<property
... /SNIP/ ...>
<one-to-one name="payload" constrained="true" />
</class>
</hibernate-mapping>
[/list]