-->
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.  [ 5 posts ] 
Author Message
 Post subject: inner fetch join results in 2 selects
PostPosted: Fri Dec 10, 2004 4:39 pm 
Newbie

Joined: Sat Oct 30, 2004 3:48 pm
Posts: 14
With hibernate 2.1.7c I can not get the full object graph to load without 2 calls to the database

Code:
class XO{
  long id;
  String xString;
  Set yset
}
class YO{
  long id;
  String yString;
  Set zset
}
class ZO{
   long id;
   String zString;
}

from XO x
  left join fetch x.yset y
  left join fetch y.zset z
  where x.id = '21'
  and y.yString = "halb"

The select hibernate creates contains all 3 elements (XO,YO,and ZO) inner joined properly

As soon as I access YO another select is generated for YO, the sql doesn't have any elements of ZO. It appears ZO is fetched eagerly but YO isn't. Is there anyway to fetch the whole graph in one query?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 4:40 pm 
Newbie

Joined: Sat Oct 30, 2004 3:48 pm
Posts: 14
I have tried both inner join fetch and left join fetch


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 4:55 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
only one collection can be fetched in a query as said in the doc

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 4:58 pm 
Newbie

Joined: Sat Oct 30, 2004 3:48 pm
Posts: 14
Could i start from the the middle, YO in this case if it has is bi directional, and fetch join X and Z?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 5:04 pm 
Newbie

Joined: Sat Oct 30, 2004 3:48 pm
Posts: 14
Yea, it works thanks! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.