-->
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: composite key
PostPosted: Thu Oct 07, 2004 6:01 pm 
Newbie

Joined: Thu Oct 23, 2003 6:12 am
Posts: 18
I have 2 tables A and B both with a composite primary key consisting of 2 columns,

My question is how would a .hbm.xml file look like for specifying a third table which has a primary key consisting of 3 columns, column 1,2 are a foreign key to table A and column 2 and 3 are a foreign key to table B.

Only if you have the time :)

Bz


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2004 3:49 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Just do the mapping as if you would have 4 columns. But you have to set the update and insert attributes to false.

Now you're left with the problem of how to write to the table.

I've solved a similar problem by defining ordinary properties for each of the foreigen key columns. I call them mirror properties.
In the onSave and onFlushDirty methods of an Interceptor you could detect, whether there are references between the Objects, if yes update the DB by setting the appropriate mirror properties.

HTH
Ernst


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.