-->
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: Left outer join without real foreign key relationship
PostPosted: Thu Jan 25, 2007 6:48 am 
Newbie

Joined: Wed Jan 24, 2007 12:01 pm
Posts: 1
Hi,

I have the problem with the following mapping situation. There are 2 tables:

Table a:
Code:
+--------------------------------------+
| PRIMKEY | FIELD1 | FIELD 2 | FIELD 3 |
+--------------------------------------+
| INT     | String | String  | String  |
+--------------------------------------+


Table b:
Code:
+-----------------------------------------+
| PRIMKEY1 | PRIMKEY2 | PRIMKEY3 | FIELD  |
+-----------------------------------------+
| String   | String   | String   | String |
+-----------------------------------------+


The primary key of table b is mapped as a composite-id. Now I want to join the 2 tables like in the following SQL.

Code:
SELECT * FROM a LEFT OUTER JOIN b ON a.field2=b.primkey1 AND b.primkey2=someval AND b.primkey3=someotherval;


I've tried various associations, but they all seem to require a real foreign key association, which is not possible, as table a doesn't have a direct relationship to primkey2 and primkey3 of table b. I've also tried sets and other collection mappings, but there seems to be no obvious way to do this. The doc doesn't explain too much about situations like this.

Is there anyone who can point me to the right direction?


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.