假设我有以下实体:
@Entity
@Table(name = "A")
public class A implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany
@JoinTable(name="A_B", joinColumns = @JoinColumn(name = "A_ID"),
inverseJoinColumns = @JoinColumn(name = "B_ID"))
private List<B> bList1;
@OneToMany
@JoinTable(name="A_B", joinColumns = @JoinColumn(name = "A_ID"),
inverseJoinColumns = @JoinColumn(name = "B_ID"))
private List<B> bList2;
// getters and setters
}
@Entity
@Table(name = "B")
public class B implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//some other data
//getters and setters
}
@JoinTable 结构类似于:
A_B (a_id, b_id, discriminator);
是否可以使用一些注释来指定鉴别器列,基于哪个 bList1 和 bList2 将被填充?