-->
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.  [ 1 post ] 
Author Message
 Post subject: join fetch multiple levels with owner not in select list
PostPosted: Thu Jul 22, 2010 2:16 pm 
Newbie

Joined: Thu May 22, 2008 9:48 am
Posts: 13
So I have A to B to C, where A to B is 1:n and B to C is 1:n. I would like to retrieve all C which are predicated on some property of A. Hence the query I'd like to run would look something like:

Code:
select c from A as a inner join fetch a.collection_of_b as b inner join fetch b.collection_of_c as c where a.prop = 'predicate value'


Now I get an exception saying that the owner of the collection is not in the select list. I have (what I believe to be) an identical query (from the perspective of the results) in this:

Code:
from C as c inner join fetch c.parent_b as b inner join b.parent_a as a where a.prop = 'predicate value'


An almost identical query to the first, but no fetches. Returns the proper results but...it executes far too many queries.
Code:
select c from A as a inner join a.collection_of_b as b inner join b.collection_of_c as c where a.prop = 'predicate value'



However, option 2 is extremely undesirable as a result of the SQL that is actually executed...any ideas on what to do?


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

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.