-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to do this outer join in HQL?
PostPosted: Fri Oct 31, 2003 10:06 pm 
Newbie

Joined: Tue Oct 28, 2003 6:00 pm
Posts: 14
I need to do the following outer join in HQL,

select req.*, e1.empName, e2.empName from request req, employee e1, employee e2 where req.codition=? and req.requestorId = e1.empId(+) and req.requesteeId = e2.empId(+)

My original query is

from Request req, Employee e1, Employee e2 where req.condition=? and req.requestorId = e1.empId and req.requesteeId = e2.empId

This is to display the details inluding requstor and requestee name of requests that meet the condition specified. The requestor/requestee will not exist in the employee table if they are no longer with the company. I have tried left join, but still can't get it work.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 10:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
from Request request
left join request.requestor requestor
left join request.requestee requestee
where request.condition = ?


or, simply:

Code:
from Request request
left join request.requestor
left join request.requestee
where request.condition = ?



but I would prefer:

Code:
from Request request
left join fetch request.requestor
left join fetch request.requestee
where request.condition = ?


And just walk the associations.


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

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.