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.  [ 4 posts ] 
Author Message
 Post subject: Problem with HQL and LEFT JOIN
PostPosted: Mon Aug 27, 2007 4:41 am 
Newbie

Joined: Mon Jun 18, 2007 3:48 am
Posts: 7
Location: FRANCE
NHibernate 1.2.0.4000

Hello,

I've got a problem with an HQL Query :

Let's consider the following mapping :

A [Person] can have many [Phone] and each [Phone] has a [PhoneType]. For example,"personal", "professiona"l and "mobile".

What I'd like to get is a list of all the persons with only their optional mobile phones.



The problem is that if I do this :
FROM Person
LEFT JOIN Person.Phones Phone
LEFT JOIN Phone.PhoneType PhoneType
WHERE PhoneType.Name = 'Mobile'

Then, I would not list the persons that don't have mobile phones.



What I missed is How should I do to write a query like :
FROM Person
LEFT JOIN Person.Phones Phone
LEFT JOIN Phone.PhoneType ON PhoneType.Name = 'Mobile'


Thank you very much for any answer.

Laurent MONDEIL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 27, 2007 11:36 am 
Newbie

Joined: Thu Aug 16, 2007 11:07 am
Posts: 9
I do not have a solution for you but I have a similar problem. I'm looking for a way to express a statement like this in HQL. Note: (+) is the Oracle Syntax for left outer join

SELECT A.id, c.position
FROM people A, department B, position C
WHERE A.id = B.id (+)
AND A.id = C.id
AND B.depid IS NULL

What it does is selecting id and position of those people who not yet have a depid.

All HQL examples I have seen did not make an outer join across different relations?! Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 2:42 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
This is a known limitation in NHibernate. A JIRA issue has been logged quite a while ago. The solution is to port the enhancements from Hibernate 3.x to NHibernate.

Please vote for the issue at http://jira.nhibernate.org/browse/NH-514


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 3:12 am 
Newbie

Joined: Thu Aug 16, 2007 11:07 am
Posts: 9
Thank you Nels,

I will vote for that issue. I was already evaluating other O/R-Mappers. For now my solutions is simply to create a View for that query or actually for a more complicated one but the reason why I didn't get it to work was the left outer join as described above. It's a very important query for our project and therefore I can justify a view but in general one does not want to clutter his schema with views just because HQL does not support a specifice query. It makes the mapping less transparent too.


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