-->
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.  [ 2 posts ] 
Author Message
 Post subject: Joining Table on Foreign Key of Primary Table
PostPosted: Sat Aug 28, 2010 9:16 am 
Newbie

Joined: Mon May 17, 2010 11:29 am
Posts: 12
I have been trying to map a legacy database using HBM file mappings and need some help getting a join to hopefully behave the way I would like. I need to join on a table using two fields, where the primary table's primary key is not the field that I would like to join on. For example:

Quote:
Table A
Key1
Field1
Field2

Table B
Key1
Key2


I need to map A.Field1 to B.Key1 and and A.Field2 to B.Key2 while using A.Key1 as my ID for the object. My object looks like this:

Code:
class Object {
  int number
  String uid
  int p_number
}


where number is A.Key1, uid is A.Field1 adn B.key1 and p_number is A.Field2 and B.Key2.

This scenario is possible when I use table B as a composite key on the Object but I need to be able to reference Table A as the Identifier since this field is the referencing field throughout the rest of the system.

Any help is much appreciated.


Top
 Profile  
 
 Post subject: Re: Joining Table on Foreign Key of Primary Table
PostPosted: Thu Sep 09, 2010 1:36 pm 
Newbie

Joined: Mon May 17, 2010 11:29 am
Posts: 12
Is this scenario not possible? I have tried many combination of the foreign-key and property-ref attributes but I don't see a way to get this to work. Any sort of confirmation one way or another would be much appreciated.


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