我正在尝试使用引用3个表的3个键的复合主键进行三元关联:REPORT,SCANNER和RISK,我试图使用下面的代码实现这个,但我只有一个复合键2个键:riskId和reportId:
Report.java
@Entity
@Table(name="REPORT")
public class Report {
@Id
@NotNull
@GeneratedValue
private int reportId;
@Column
private String reportName;
@OneToMany
@MapKeyJoinColumn
Map<Risk, Scanner> risks = new HashMap<Risk, Scanner>();
}
Scanner.java:
@Entity
@Table(name="SCANNER")
public class Scanner{
@Id
@NotNull
@GeneratedValue
private int scannerId;
@Column
private String scannerName;
}
Risk.java:
@Entity
@Table(name="RISK")
public class Risk {
@Id
@NotNull
@GeneratedValue
private int riskId;
@Column
private String issueName;
}
那么如何使用3个键实现复合主键?