-->
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: HQL - Outer join with multiple conditions
PostPosted: Mon Aug 24, 2009 8:42 pm 
Newbie

Joined: Fri Jul 03, 2009 1:32 am
Posts: 7
Hi,
I have 2 tables Member and Employ both are mapped to a third table Qual_Def through the mapping table Qual_Mapping.

Sample data

Member

m_id || m_name

1 || John
2 || Taylor
3 || Martin

Employ
e_id||e_name

1||Peter
2||Stacey
3||Lisa

Qual_Map

qmap_id||m_p_id||q_id||map_type

1||1||10||M
2||1||20||M
3||2||10||M
4||3||30||E

Here q_id is the QaulDef id and map_type is a discriminator which will help to identify its a Member or Employ.
Now I want to retrieve all the Member and their qualifications. Hence I am using HQL and a left outer join from Member to Qual_Map. Here the issue is , this will show me that Martin have a qualification (where he does not have one). This is incorrect because the qaulification 30 is mapped to Lisa, an employ. I can put an additional filter criteria in SQL like
Code:
select M.* from Member M
left outer join Qual_Map Q on (M.M_ID=Q.M_P_ID and Q.MAP_TYPE='M');

But I don't know how can we make this possible using HQL.
Can anybody suggest ?
Note:I do not wish to use native SQL

Thanks in advance
SHaiju


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.