如何用Hibernate映射复合密钥?在本代码中,如何为组合键生成Java类(如何在Hibernate中组合键):create table Time (
levelStation int(15) not null,
src varchar(100) not null,
dst varchar(100) not null,
distance int(15) not null,
price int(15) not null,
confPathID int(15) not null,
constraint ConfPath_fk foreign key(confPathID) references ConfPath(confPathID),
primary key (levelStation, confPathID)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
3 回答
三国纷争
TA贡献1804条经验 获得超7个赞
@EmbeddedId:
@Entityclass Time {
@EmbeddedId
TimeId id;
String src;
String dst;
Integer distance;
Integer price;}@Embeddableclass TimeId implements Serializable {
Integer levelStation;
Integer confPathID;}添加回答
举报
0/150
提交
取消
