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