【发布时间】:2015-02-06 10:38:16
【问题描述】:
我如何在hibernateo表中建模,主键也是外键
作为这个架构:
CREATE TABLE policies (
policy_id int,
date_issued datetime,
-- // other common attributes ...
);
CREATE TABLE policy_motor (
policy_id int,
vehicle_reg_no varchar(20),
-- // other attributes specific to motor insurance ...
FOREIGN KEY (policy_id) REFERENCES policies (policy_id)
);
CREATE TABLE policy_property (
policy_id int,
property_address varchar(20),
-- // other attributes specific to property insurance ...
FOREIGN KEY (policy_id) REFERENCES policies (policy_id)
);
- 这在休眠映射中是否可能,或者最好是分开 他们并使用新的PK?
- 如果我在主表上使用自动增量也没关系
【问题讨论】:
标签: java mysql sql hibernate jpa