-->
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.  [ 8 posts ] 
Author Message
 Post subject: Using left outer gives me Path expected for join
PostPosted: Tue Jan 09, 2007 12:47 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Hibernate version: 3.1.3

I need to create a left outer join between two tables that have no mapping relationship. From what I've seend I need to create a mapping relationship between the two tables. Is there a way to create a left outer join without using a mapping relationship.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 5:08 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Well from what I have investigated the only way to use an outer join is using a path. There is no way with Hibernate to do:

select *
from tablea a left outer jin tableb b on a.col1 = b.col2

without using an existing one-to-many or many-to-many mapping


Top
 Profile  
 
 Post subject: Are you sure...?
PostPosted: Thu Jan 11, 2007 12:10 pm 
Beginner
Beginner

Joined: Thu Nov 13, 2003 4:12 am
Posts: 27
Hi, same problem here. I cannot belive that this is not possible.
The join ... on syntax should be supported, shouldn't it?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 4:05 am 
Newbie

Joined: Sun Oct 29, 2006 3:58 pm
Posts: 1
Location: istanbul
Hi, same problem. Is this a missing functionality, or is this normal in Hibernate programming model? If this is normal, than what should we do to solve this problem?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 11:08 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
it looks like a missing functionality


Top
 Profile  
 
 Post subject: I think I have a solution
PostPosted: Wed Jun 06, 2007 7:10 am 
Newbie

Joined: Mon Jan 15, 2007 6:27 am
Posts: 7
This kind of join can be done in Hibernate using "theta-style" joins (the old way to join).

For example - instead of:

select *
from tablea a left outer jin tableb b on a.col1 = b.col2

Use this syntax:

from tablea a, tableb b
where a.col1 = b.col2

Each row in the result would be an Object array with 2 elements, the first would be tablea (the corresponding object), the second would be tableb.

You can also use this syntax so that each row will be a map:

select new map(a as ta, b as tb) from tablea a, tableb b ...

Now each row will be a map:
{ta=tablea object, tb=tableb object}

HTH


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2008 3:40 pm 
Newbie

Joined: Mon Dec 22, 2008 3:35 pm
Posts: 1
The solution shown

Quote:
from tablea a, tableb b
where a.col1 = b.col2


doesn't really return an outer join but a inner join, right ?

That is, you won't have a if b doesn't exist...

is there any other solution for that ?


Top
 Profile  
 
 Post subject: same problem
PostPosted: Wed Apr 08, 2009 4:20 pm 
Newbie

Joined: Tue Oct 26, 2004 3:55 pm
Posts: 5
I'm having the same problem as I try to convert a lot of native SQL queries into HQL. If it has to be kept as native SQL, is there an easy way to do a mapping in native SQL like in HQL such as:
Code:
select new map(a, b)
from table1 a, table2 b


Thanks


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