年级和宣教士有一对多的关系,一个年级有很多宣教士。
grade和dept_gen具有多对一关系。一个dept_gen有许多等级。 传教士与dept_gen有多对一关系,一个dept_gen有许多传教士。当与邮递员进行测试时,我填满了所有表格,因此它们不为空。
并且有dept_gen实体
当我尝试发布“任务表”时出现错误,并且当我尝试发布没有等级的任务表时出现错误。
宣教士:
@Id
@Column(name="CIN")
private String cin;
@JoinColumn(name = "CODE", referencedColumnName = "CODE")
@ManyToOne
private DeptGen code;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumns({
@JoinColumn(name = "CODE",referencedColumnName = "CODE" , insertable=false, updatable=false)
, @JoinColumn(name = "COD_GRD",referencedColumnName="COD_GRD" , insertable=false, updatable=false)})
private Grade grade;
and this is grade :
@EmbeddedId
private GradePK gradePK;
...other columns ..
@MapsId("code")
@JoinColumn(name = "CODE", referencedColumnName = "CODE", nullable = false, insertable = false, updatable = false)
@ManyToOne(optional = false, fetch = FetchType.EAGER)
private DeptGen deptGen;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "grade", fetch = FetchType.EAGER)
private Collection<Missionnaire> missionnaireCollection;
@JsonIgnore
public Collection<Missionnaire> getMissionnaireCollection() {
return missionnaireCollection;
}
... 这是gradePK: @Embeddable 公共类GradePK实现了Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "CODE")
private String code;
@Column(name = "COD_GRD")
private String codGrd;
这是dept_gen类,因为宣教员和职系与之有关:
private static final long serialVersionUID = 1L;
@Id
@Column(name = "CODE")
private String code;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "deptGen")
@JsonIgnore
private Collection<Fonction> fonctionCollection;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "deptGen")
@JsonIgnore
private Collection<Grade> gradeCollection;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "code")
@JsonIgnore
private Collection<Missionnaire> missionnaireCollection;