Hibernate version:
Hibernate 3
Name and version of the database you are using:
MySQL 5
I would like to generate complex outer joins with HQL.
For example:
(you must assume the usual map files and pojos)
two tables like these:
questions
answers - id (PK)
- idQuestion (FK on questions)
- idPerson (FK on People)
- answer
With SQL I can ask for:
Code:
select
q.question,
a.answer
from
question as q
left outer join answer as a
on
a.idQuestion = q.id
and
a.idPerson = 666
With it, I can get
ALL the questions along with the existing answers of person with id 666.
With HQL I can do something like this:
Code:
select
q,
a
from
question as q
left outer join q.answers as a
BUT, how I could intro the person restriction?????
This doesn't work
Code:
select
q,
a
from
question as q
left outer join q.answers as a
where
a.person = :person
Because it
only gives me the questions where exists an answer.
Any hint???