我试图将一个外键链接到多个3个实体,因此外键列可以将这3个实体中的一个主键作为值,这可能吗?
在这段代码中,我试图将这3个外键分配给列操作
public class workflow {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_operation", insertable=false, updatable=false)
private demande_de_conge demande_de_conge;
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_operation", insertable=false, updatable=false)
private annulation annulation;
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_operation", insertable=false, updatable=false)
private regularisation regularisation;
}
public class demande_de_conge {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id_demande;
@JsonIgnore
@OneToMany(mappedBy="demande_de_conge", cascade = CascadeType.ALL, orphanRemoval = true)
private List<workflow>workflow;
}
public class regularisation {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id_regularisation;
@JsonIgnore
@OneToMany(mappedBy="regularisation", cascade = CascadeType.ALL, orphanRemoval = true)
private List<workflow>workflow;
}
public class annulation {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id_annulation;
@JsonIgnore
@OneToMany(mappedBy="annulation", cascade = CascadeType.ALL, orphanRemoval = true)
private List<workflow>workflow;
}
1条答案
按热度按时间jm81lzqq1#
在你的情况下,你可以试试这个: