-->
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 left outer join
PostPosted: Mon Nov 20, 2006 3:59 pm 
Newbie

Joined: Tue Oct 11, 2005 10:57 am
Posts: 13
Why this hql do not execute the outer join? The result it's like just a inner join (Hibernate ignores the outer join)!

Code:
from Programa as prg
      left outer join fetch prg.credenciamentos as cre
      inner join fetch cre.professorCredenciado as prc
      inner join fetch prc.pessoa as pes
where cre.status = 'P'
order by prg.nome asc, pes.nome asc;


I alredy tried to in this form:

Code:
from Programa as prg
      left outer join fetch prg.credenciamentos as cre
order by prg.nome asc;


But still don't work!

I'm using Hibernate 3.0.5 and Postgre 8.1.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 8:00 am 
Newbie

Joined: Tue Oct 11, 2005 10:57 am
Posts: 13
No one?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 7:35 am 
Newbie

Joined: Mon Nov 27, 2006 6:16 am
Posts: 5
If you look at the generated SQL, you will see, that all JOINs are applied in a flat manner, from left to right. That means, that any inner join affects the result. You would need to add parentheses to create a composite "sub-join". I can't explain it more accurately now.

Please post the generated SQL and I will reply with a modified SQL. What I am afraid is, that you can't really control the composition of join in HQL. I have a similar problem at the moment ...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2008 3:46 am 
Newbie

Joined: Thu Jan 12, 2006 7:41 am
Posts: 10
Location: Lyon - France
I think that the following hql may solve your problem :

from Programa as prg left join prg.credenciamentos as cre where cre.professorCredenciado is not null or prg.credenciamentos is empty

_________________
Olivier Hanny
Senior Software Engineer
http://www.icodem.fr


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.