Composite-id hibernate复杂的映射

时间:2012-11-09 07:29:34

标签: java hibernate hibernate-mapping composite-key composite-primary-key

我有3张桌子A,B,C

Table A (
idA1 int unsigned not null,
idA2 int unsigned not null,
primary key(idA1, idA2)
)

Table B (
idB1 varchar(36) not null,
primary key(idB1)
)

Table C (
idC1 int unsigned not null,
idC2 varchar(36) not null,
idC3 int unsigned not null,
primary key(idC1, idC2, idC3),
foreign key(idC1, idC2) references A(idA1, idA2),
foreign key(idC3) references B(idB1)
)

我使用composite-id作为键表A,但后来遇到问题映射表C. 如何使用下一个结构进行hibernate映射?

1 个答案:

答案 0 :(得分:2)

我找到了解决问题的好方法

Solution