Beginner |
|
Joined: Wed Apr 13, 2005 2:03 pm Posts: 34
|
Hibernate 3.0
mySQL 4.1.10
I have a pair of classes linked via a one-one join on pk (mapping below). The reason I put the attachmentdata in another object(and table) is that it's *big* as in megabytes and I really, really don't want to be yanking it out of the database unless I need it. So I want to just query out the Attachments (without their big data blobs) and list them.
I have the data classmapped as "lazy".
Whenever I initialize a collection of Attachments though, Hibernate is doing a left outer join for me and pulling up the data as well.
How can I force hibernate to treat the attachmentdata as a lazy relationship?
<hibernate-mapping>
<class name="attachment.Attachment" table="attachment">
<id name="id" type="string" length="32">
<column name="id" length="32" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="fileName" column="filename" type="string"/>
<property name="objectClass" column="objectclass" type="string"/>
<property name="length" column="length" type="long" />
<property name="objectId" column="object_id" type="string" length="32" />
<one-to-one lazy="true" name="detail" ></one-to-one>
</class>
<class name="attachment.AttachmentData" table="attachmentdata">
<id name="id" column="id">
<generator class="foreign">
<param name="property">attachment</param>
</generator>
</id>
<one-to-one lazy="true" name="attachment" constrained="true"/>
<property name="data" column="data" type="binary" length="100000000" />
</class>
</hibernate-mapping>
|
|