-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help with outer joins.
PostPosted: Mon Aug 11, 2008 2:20 am 
Newbie

Joined: Fri Aug 08, 2008 9:38 am
Posts: 3
How do I get a full join of two tables unrelated from Hibernate perspective.

I have a requirement to join two tables not mapped with hibernate. I want something like:

Code:
List list=session.createQuery("select a,b from A a full join B b on a.col1=b.col1 where VERY LONG WHERE CONDITION").list();

Code:
list
is a list of Object[]. Object[1] should be null when it does not have a link and viceversa.

I guess I can do a left/right outer join using "NOT EXIST" clause.
But in this case, I end up executing 3 queries (1 inner join, 1 left, 1 right), with the same where condition.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 5:53 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Hibernate has currently no support for using the JOIN keyword with unrelated classes. However, as long as you don't need a left or right join the following will work:

Code:
select a,b from A a, B b where a.col1=b.col1 and VERY LONG WHERE CONDITION


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 11, 2008 5:59 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Ok, I guess my last post didn't add very much since the question was about a full join which includes both a left and right join. The short answer is that this is not possible. However, I think some work has been done on this and may be included in a future Hibernate version. See http://opensource.atlassian.com/project ... wse/HHH-16 for more information.


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