-->
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: Query with partial child data fetching
PostPosted: Fri Jul 08, 2005 9:53 am 
Beginner
Beginner

Joined: Fri Jul 08, 2005 8:09 am
Posts: 28
Hi,

I am executing an HQL query like this:

Code:
select c, ct.title, r
from Course c, Request r, CourseTypeVersion ctv, CourseType ct
where c.courseStart >= ? and c.courseStart < ? and c.id.request = r
  and r.courseTypeVersion = ctv and ctv.courseType = ct
order by c.courseStart, ct.title


This returns a list of Object[] instances and works well with a single SQL statement. The Request object has a one-to-many field which I want to be populated, too. It also has a few other one-to-many fields which I don't need at this time.

What is the best way to load this single one-to-many field in the same query or just one more query?

Currently I am collecting the Request.Ids, and then execute another query on the child data with a Restrictions.in clause and then manually distribute the child data to the various Request objects. Can Hibernate assist me with this? I tried to add a "left join fetch" clause but did not get the syntax right - and I have not found a syntax diagram for HQL.

And additionally, the child data mentioned actually is a m:n table. This means the Request is only one part of its Id. What can I do to load the other referenced entity (in m:n the "n" part) in one go for all the loaded objects?

Hibernate version: 3.05
Name and version of the database you are using: Oracle v8-10


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.