-->
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 join
PostPosted: Fri Mar 03, 2006 1:05 pm 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
Hello,

I am quite new in NHibernate. I wrote some simple queries for my application using HQL, but now, I need to write another one, which is very simple in SQL but I don't know how to write it using HQL.

I need to left outer join one table but constraint a join with additional condition. The query in SQL follows:

Code:
select parent.id_parent, child.id_child
from parent
  left join child on child.id_parent = parent.id_parent and child.status != 'A'


But using HQL, I am only able to generate this query:

Code:
select parent.id_parent, child.id_child
from parent
  left join child on child.id_parent = parent.id_parent
where child.status != 'A'


Please is it possible in any way to put the condition from WHERE clause to JOIN clause? These two queries are returning different results.

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 11, 2006 6:19 pm 
Beginner
Beginner

Joined: Sat Dec 10, 2005 6:22 pm
Posts: 28
Location: Chicago, IL
I believe this issue was documented in jira NH-514


Top
 Profile  
 
 Post subject: ON clause
PostPosted: Mon Mar 13, 2006 5:37 am 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
OK. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 1:30 pm 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
try this:

select parent.id_parent, child.id_child
from parent
left join child on child.id_parent = parent.id_parent
where (child.id is null or child.status != 'A')


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.