-->
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: question about shared composite key
PostPosted: Mon Jun 21, 2004 1:09 pm 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Hi,
Table A has following keys forming primary keys:
Ayear, Adate, Anumber, Astring

Table B has references to following keys plus some other keys foming the primary key:
Ayear, Adate, Anumber, Astring, Bone, Btwo

How do i correctly map the compiste primary key of Table A with that of table B with its own set of additional keys forming the primary key?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 9:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
many-to-one or a one-to-many depending which side we are talking about.
The manual has a section on composite keys.

http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-compositeid

You could try out a tool like Middlegen and see what it generates.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 10:40 am 
Newbie

Joined: Mon Jun 21, 2004 12:58 pm
Posts: 15
Its a one-to-many from Table A to Table B. I can create a composite id for table A just fine. Table B has foreign key references to these composite keys + plus its own additional fields that make up its primary key(composite id for Table B).

How do i map this relation in hibernate mapping file?


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.