-->
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.  [ 4 posts ] 
Author Message
 Post subject: left join fetch
PostPosted: Mon Feb 09, 2004 2:29 pm 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Hello,

I'd like to get some help on this simple issue, possibly due to my ignorance of SQL.

I have a simple class that contains a set mapped as one-to-many. When I use the left join fetch to hidrate the collection with one select, I get as a result each one class of the 'one' end of the relation per item found on the many.
Maybe I wrongly assumed that I'd get the 'one' class and hibernate would add each of the items found for the 'many' side to the collection.

My mappings follow:

<class name="net.Property" table="property" dynamic-update="true">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="name" column="property_name"/>
<property name="type" column="property_type"/>
<property name="rooms" column="number_of_rooms"/>
<property name="bathrooms" column="number_of_bathrooms"/>
<property name="floors" column="number_of_floors"/>
<property name="orientation"/>
<property name="status"/>
<property name="summary"/>
<property name="description"/>
<property name="price"/>
<property name="nativeCurrency" column="native_currency"/>
<property name="currency"/>
<property name="partnerId" column="partner_id"/>
<property name="userId" column="user_id"/>
<property name="visible" type="boolean"/>
<property name="creationDate" column="creation_date"/>
<property name="lastModifiedDate" column="last_modified_date"/>
<property name="offMarketDate" column="off_market_date"/>

<component name="address" class="net.Address">
<property name="street1" column="address"/>
<property name="city"/>
<property name="location"/>
<property name="country"/>
<property name="state" column="state_province"/>
<property name="postcode" column="postcode"/>
</component>

<set name="pictures" cascade="all" lazy="true" inverse="true">
<key column="property_id"/>
<one-to-many class="net.Picture" />
</set>

<set name="auditLog" cascade="delete" lazy="true" inverse="true" order-by="access_date desc">
<key column="property_id"/>
<one-to-many class="net.Audit" />
</set>
</class>



And for the 'many' side:

<class name="net.Picture" table="picture">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<property name="propertyId" column="property_id" insert="false" update="false"/>
<property name="pictureName" column="picture_name"/>
<property name="thumbnailName" column="thumbnail_name"/>
<property name="pictureURL" column="picture_url"/>
<property name="thumbnailURL" column="thumbnail_url"/>
<property name="pictureWidth" column="picture_width"/>
<property name="pictureHeight" column="picture_height"/>
<property name="thumbnailWidth" column="thumbnail_width"/>
<property name="thumbnailHeight" column="thumbnail_height"/>
<property name="visible" type="boolean"/>
<many-to-one name="property" column="property_id" cascade="none" not-null="true" />
</class>

Cheers
jorge

_________________
The first rule of http://www.jpolls.net is you do not pay for jpolls


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is a known behaviour. http://www.hibernate.org/74.html#A4


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 3:05 pm 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Ah, ok. Sorry about that, it seems I overlooked that.

Now could I get an expert opinion on the advantages of that? I save database hits for the extra memory search burden. What should be the threshold, the point of no return? At the moment I'm returning a couple of hundreds of those Property classes. What if it escalates to 1000s? Which approach is more scalable, you reckon?

Cheers
jorge

_________________
The first rule of http://www.jpolls.net is you do not pay for jpolls


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 3:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Thats a very vague question. What you should do is ask your DBA for advice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.