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]
|