-->
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: Problem in specifying properties for Secondary table
PostPosted: Tue Sep 16, 2008 6:21 am 
Newbie

Joined: Tue Sep 16, 2008 5:46 am
Posts: 3
Hi,

I am using -
Hibernate version: 3.0
Name and version of the database you are using:MySQL

I have the following requirement at the DB level and Object Model Level -


Table A - F_ID and SEQ_ID are the composite primary key for TableA
---------
F_ID
SEQ_ID

Table B - F_ID and SEQ_ID are the foreign key from Table A and composite primary key for Table B
---------
F_ID
SEQ_ID


Table C -
F_ID and SEQ_ID are the foreign key from Table A and composite primary key for Table C

PARENT_F_ID and PARENT_SEQ_ID are the foreign key from table B
---------
F_ID
SEQ_ID
PARENT_F_ID
PARENT_SEQ_ID

Coming to defining objects, I have following -

1. ModelA - This is mapped to Table A
2. ModelAPK - for composite primary key
3. ModelB - This has all the fields from Table B and Table C

Now I want to define a SecondaryTable for ModelB refering to Table C.

@Entity
@Table(name="Table B")
@SecondaryTable(name="Table C",
pkJoinColumns={@PrimaryKeyJoinColumn(name="PARENT_F_ID",referencedColumnName="F_ID"),
@PrimaryKeyJoinColumn(name="PARENT_SEQ_ID",referencedColumnName="SEQ_ID")}
)

public class ModelC{
}

How do I declare two composite primary keys? One for Table B and another for Table C?

When I try the above mapping, PARENT_F_ID and PARENT_SEQ_ID become primary key for Table C which I donot want.

Please help.

Thanks,
Manu

[/img]


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.