-->
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: Proble with LEFT JOIN and the ON Part
PostPosted: Thu Jul 05, 2007 9:12 am 
Newbie

Joined: Mon Jun 18, 2007 3:48 am
Posts: 7
Location: FRANCE
Hibernate version: 1.0.2.4000

hi,

I'm working on a project using NHibernate and the UML Model I Work with is the following :

[Contact]--->[Phone]--->[PhoneType] where PhoneType can be one of the following values :
* Personal
* Business

I try to write an HQL Query that returns all the contacts associated with their potential business phone number.

-----------------------------------------------------------------------------

Considering the documentation, it shoud look like this exept the LEFT JOIN part where "ON" are not allowed :

SELECT Contact.LastName, Contact.FirstName, BPhone.Number
FROM Contact Contact
LEFT JOIN Contact.Phones BPhone ON Phone.PhoneType.Name = 'Business'

-----------------------------------------------------------------------------


Then I tried this HQL query :

SELECT Contact.LastName, Contact.FirstName, BPhone.Number
FROM Contact Contact
LEFT JOIN Contact.Phones BPhone
WHERE BPhone.PhoneType.Libelle = 'Business'

But the proble then is that the "WHERE" filter removes all the contacts not having business phone.


------------------------------------------------------------------------------

Could anyone tell me how I shoud do to return the right result please.

Thank you for any answer.


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.