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: How can i map multiple primary keys in a table into the hbm?
PostPosted: Wed Feb 15, 2006 8:08 am 
Newbie

Joined: Wed Feb 01, 2006 10:33 am
Posts: 15
I have two tables tableA and tableB each with their aID and bID primary keys.

I also have another tableC who consists of 3 fields, the two first being foreign keys aID and bID - which both make the primary key together.

My questions are these:

1) How can I tell hibernate to use both these as a combined primary key in the tableC.hbm.xml mapping file?

2) Can someone please show me in code how to write the hibernate mapping for the ID tags in tableC.hbm.xml?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 8:28 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi,

1. Yes.

2.
<composite-id>
<key-property name="pk1" type="java.lang.Long" column="PK1" />
<key-property name="pk2" type="java.lang.Long" column="PK2" />
</composite-id>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 8:41 am 
Newbie

Joined: Wed Feb 01, 2006 10:33 am
Posts: 15
Thanks :-) very helpful!


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.