-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL: How to write left outer join in HQL
PostPosted: Fri Jan 27, 2006 3:20 am 
Newbie

Joined: Thu Jan 26, 2006 11:31 pm
Posts: 2
Hi,

My system is using mysql database. I am trying to write a left outer join SQL in HQL. I had tried to write it in HQL, but the count is not same as the one executed thru MySQL query browser. My sql query is as follows:

SELECT c.company_name, d.department_name, u.unit_name, count(s.staffno)
FROM staff s
LEFT OUTER JOIN company c on c.id = s.company_id
LEFT OUTER JOIN department d on d.id = s.department_id
AND d.company_id = c.id
LEFT OUTER JOIN unit u on u.id = s.unit_id
AND u.company_id = c.id
AND u.department_id =d.id
GROUP BY c.company_name, d.department_name, u.unit_name

Can anyone help me out? Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 4:21 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Can you post the HQL?
We are trying something else too.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 5:17 am 
Newbie

Joined: Thu Jan 26, 2006 11:31 pm
Posts: 2
The SQL in HQL would be:

SELECT company.companyName, department.departmentName, unit.unitName, count(staff.staffNo)
FROM staff in Staff,
company in Company,
department in Department,
unit in Unit
WHERE company.Id = staff.companyId
AND department.Id = staff.departmentId
AND department.companyId = company.Id
AND unit.Id = staff.unitId
AND unit.companyId = company.Id
AND unit.departmentId = department.Id
GROUP BY company.companyName, department.departmentName, unit.unitName


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.