-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Can I make a one-one relationship lazy?
PostPosted: Fri May 13, 2005 5:11 pm 
Beginner
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>


Top
 Profile  
 
 Post subject: This seemed to work
PostPosted: Fri May 13, 2005 6:28 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 2:03 pm
Posts: 34
In case anyone else gets stumped on this

<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 outer-join="false" lazy="true" name="detail" constrained="true"></one-to-one>
</class>
<class name="attachment.AttachmentData" proxy="attachment.AttachmentData" lazy="true" table="attachmentdata">
<id name="id" column="id">
<generator class="foreign">
<param name="property">attachment</param>
</generator>
</id>
<!--
<one-to-one lazy="true" outer-join="false" name="attachment" constrained="true"/>
-->
<property name="data" column="data" type="binary" length="100000000" />
</class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.