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.  [ 1 post ] 
Author Message
 Post subject: Multiple Right Outer Joins
PostPosted: Thu Feb 22, 2007 12:28 am 
Newbie

Joined: Wed Feb 21, 2007 11:49 pm
Posts: 1
I've created a query for MSSQL which is exactly what i need to fulfill my requirement. I need to translate this into HQL. however due to the complexity of the query I'm having some trouble.

The query is:

select distinct P.firstname, P.lastname, S1.name
from dbo.Person P
LEFT OUTER JOIN dbo.Store S1 ON
(P.Id = S1.propertyManagerPersonId OR
P.id = S1.areaManagerPersonId OR
P.id = S1.storeManagerPersonId)



Currently, I have the following HQL:

select distinct p, s from Store s
right outer join s.areaManager as p
right outer join s.propertyManager as p
right outer join s.storeManager as p


The problem with the HQL is that it doesn't return as many rows as the SQL. A Co-worked suggested that the HQL may only joining on s.storeManager, and none of the others.

I have also tried (along with many other variations)

select distinct p, s from Store s
right outer join (s.areaManager OR s.propertyManager OR s.storeManager ) as p



This is the segment of generated SQL regarding the joins:
from Store store0_ right outer join Person person1_ on store0_.areaManagerPersonId=person1_.id right outer join Person person2_ on store0_.propertyManagerPersonId=person2_.id right outer join Person person3_ on store0_.storeManagerPersonId=person3_.id where (person3_.customerId=? )and(person3_.statusId='ENABLED' )

ANY help is greatly appreciated.

Thanks


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

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.