-->
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: HQL left outer join with criteria
PostPosted: Wed Oct 15, 2003 10:54 pm 
Newbie

Joined: Wed Oct 15, 2003 10:24 pm
Posts: 10
How can I do a left out join two tables while specifing criteria for the table being outer joined to?

In regular SQL i would do something like:
select tabA.*, tabB.*
from tableA as tabA left outer join tableB as tabB on (tabA.id = tabB.parentId and tabB.type = 'X')

in HQL I don't think I can use the ON keyword so I think my only option is:
select tabA, tabB
from tableA as tabA left outer join tabA.bees as tabB
where (tabB.type = 'X' or tabB.type is null)


Is this correct... or is there a more elegant way?

Thanks,
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 6:32 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 9:50 am
Posts: 34
Location: Weiden Opf. / Germany
Besides that it only works for simple joins anyway. I don't have the slightest clue how to put somthing like this in the where condition:

from tbTechnician as T
left outer join tbTechnicianSlots as TS on TS.technicianActorID = T.technicianActorID
left outer join tbTechnicianSlots as TS2 on TS2.technicianActorID = TS.technicianActorID and TS2.timeTo <= TS.timeFrom and TS2.tbCalendarID = TS.tbCalendarID and TS2.technicianAppointmentStatus = 1
left outer join tbTechnicianAppointmentSlots as TS3 on TS3.technicianActorID = TS.technicianActorID and TS3.timeFrom >= TS.timeTo and TS3.tbCalendarID = TS.tbCalendarID and TS3.technicianAppointmentStatus = 1


what i'm trying to do is find for each slot with a timeFrom and timeTo all previous slots and next slots on the same day for the same technician.


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.