Resume 和其他三张表一对多关联:
@OneToMany(fetch = FetchType.EAGER,targetEntity=EducationBackground.class,cascade={CascadeType.ALL},orphanRemoval=true)
// @Cascade(value={org.hibernate.annotations.CascadeType.ALL})
// @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name="resume_id")
public List getEducationBackground() {
return educationBackground;
}
public void setEducationBackground(List educationBackground) {
this.educationBackground = educationBackground;
}
@OneToMany(targetEntity=WorkExperience.class,fetch = FetchType.EAGER,cascade={CascadeType.ALL},orphanRemoval=true)
@JoinColumn(name="resume_id")
public List<WorkExperience> getWorkExperience() {
return workExperience;
}
public void setWorkExperience(List<WorkExperience> workExperience) {
this.workExperience = workExperience;
}
@OneToMany(targetEntity=Skills.class,fetch = FetchType.EAGER,cascade={CascadeType.ALL},orphanRemoval=true)
@JoinColumn(name="resume_id")
public List<Skills> getSkills() {
return skills;
}
public void setSkills(List<Skills> skills) {
this.skills = skills;
}
插入数据时,我提交一个请求,结果主表给我添加了两条数据,第二条为空:
第二条数据只有主键有值,其他全为空,再次提交时就报错了:
严重: Exception occurred during processing request: detached entity passed to persist: com.resume.demain.Resume