【发布时间】:2015-06-17 00:30:18
【问题描述】:
我将实体 A 的 ID 更改为复合 ID。实体 B 也有一个 PK 类,关系的一侧是实体 A。我应该如何更改我的 PK 类代码?我应该使用 IdClass 代替 Id 吗?
public class BPK implements Serializable{
// I need to change this single Id to a composite Id to include 2 columns from Entity A instead of only one id attribute
@Id
@Column(name = "aid")
private Integer a;
@Id
@Column(name = "bid")
private Integer b;
}
A级PK
public class APK implements Serializable{
@Id
@Column(name = "id")
private Integer id;
@Id
@Column(name = "project_mode")
private Integer project;
}
【问题讨论】:
标签: java jpa many-to-many eclipselink