-->
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: many-to-many mapping with complex DB model
PostPosted: Tue Mar 29, 2005 10:32 am 
Newbie

Joined: Mon Mar 28, 2005 10:57 am
Posts: 1
Hi,

I have a strange problem for defineing one-to-many or many-to-many relationships with below tables and their relationships.

Table_A has composite keys with COLUMN_1 and LOC. Table_B has COLUMN_6 and LOC. When I try to map TableA_B as many-to-many, Hibernate not allowing me to use LOC twice for key declarations. I have composite PKs in all tables and LOC is one of compound PKs. Hibernate rejecting me to declare LOC twice in mapping file. If I have not used, it says we have to declare same number of Primary keys as compound primary keys.

Please advice me to come out from this problem.


Table_A Table_B Table_A_B
----------------------------------------------------------------
COLUMN_1 (PK) COLUMN_6 (PK) COLUMN_1 (PK)
LOC (PK) LOC (PK) COLUMN_6 (PK)
COLUMN_3 COLUMN_7 LOC (PK)
COLUMN_4 COLUMN_8


class TableA {
public String column1;
public String loc;
public String column3;
public String column4;
}

class TableB {
public String column6;
public String loc;
public String column7;
public String column8;
}


<hibernate-mapping>
<class name="TableA" table="TABLE_A">
<composite-id >
<key-property name="column1" column="COLUMN_1" />
<key-property name="loc" column="loc" />
</composite-id>
</class>

<class name="TableB" table="TABLE_B">
<composite-id >
<key-property name="column6" column="COLUMN_6" />
<key-property name="loc" column="loc" />
</composite-id>
</class>

thanks,
Seshagiri T.V.


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.