-->
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: nested fetch in HQL
PostPosted: Wed Jun 11, 2008 6:59 am 
Newbie

Joined: Wed Jun 11, 2008 6:36 am
Posts: 10
Hi i have the following structure of object

Grid
---Row (first level has a parentRow = null)
------SubRows ... (which is actually a Row that its parent Row is not null)
------Cells
---Cells


as you can se i have a grid that has one or more rows, and each row has one or more cells. and this row may have one or more subrows which also have one or more cells.

i want to write a query that loads the entire structure of the grid in one select, using joins. if i am writing for one level supposing that there are no subrows i would do something like this:

from Grid grid left join fetch grid.rows r left join fetch r.cells where grid.id = :id

which will load the grid object and the collection of rows and the collection of cells for each row.



however i want to load also the subrows and their corresponding cells, so i am using something like this:

from Grid grid left join fetch grid.rows r left join fetch r.cells left join fetch r.childRows where grid.id = :id

but when i do the following:
grid.getRows().iterator().next().childRows.iterator().next().getId()

I get an exception of type java.util.NoSuchElementException.



i don't want to make the fetching strategy in the class mapping, i want to load all the grid hirearchy in one query using HQL.

any help ??
thanx in advance.


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.