-->
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: How to map strange PK/FK relationship
PostPosted: Mon Jun 07, 2004 9:50 am 
Newbie

Joined: Mon Jun 07, 2004 9:08 am
Posts: 5
Posting code and XML snippets may make this question harder than it is, so I'll refrain from doing that.

Many of the tables in our database have compound primary and foreign keys. And quite often, the primary key contains a foreign key back to another table. This is all fine until the primary key actually contains two foreign keys back to two different tables, and one of the components of the compound key is shared between the two FKs...

Clear as mud?

Picture three tables:
TABLE1 has a PK, column A
TABLE2 has a PK, column A and Column B. Column A is a FK back to TABLE1
TABLE3 has a PK, column A, Column B, and Column C. Column A is a FK back to TABLE1, and columns A,B are a FK back to TABLE2


So, I was able to map TABLE3 by using a key-many-to-one relationship to TABLE2, and a many-to-one relationship to TABLE1. Is this the correct mapping, even though column A is actually part of the PK of TABLE3 and should really be mapped as a key-many-to-one? If I map it as a key-many-to-one I get a duplicate mapping exception (which makes sense).


Thanks!

--Mark J


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.