我有 2 个实体使用与主键相同的序列,我该如何映射?例子:
@Entity
@Table("employeT")
public class Employe(){
@SequenceGenerator(name = "generator_id", sequenceName = "seq_id")
@GeneratedValue(generator = "generator_id")
@colunm(name = "id")
private Integer id;
@colunm(name = "nameEmp")
private String name;
@JoinColumn(name = "id")
private Computer computer;
}
@Entity
@Table("computerT")
public class Computer(){
@SequenceGenerator(name = "generator_id", sequenceName = "seq_id")
@GeneratedValue(generator = "generator_id")
@colunm(name = "id")
private Integer id;
@colunm(name="name_computer")
private String nameComputer;
}
我需要用相同的 id 保存员工和计算机,由 Employe save 生成。