qq_34880854
温柔写的伤
采纳率0%
2016-05-30 01:19 阅读 1.2k

SSH框架save()数据时的问题,求大神帮忙看一下

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
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • qq_34880854 温柔写的伤 2016-05-30 01:24

    各位大神 帮帮忙,本人初学不是太懂

    点赞 评论 复制链接分享
  • imlt1234 imlt1234 2016-05-30 01:40

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "xx") 这是一对多

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "xxx") 这是多对一

    点赞 评论 复制链接分享
  • imlt1234 imlt1234 2016-05-30 01:40

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "xx") 这是一对多

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "xxx") 这是多对一

    点赞 评论 复制链接分享

相关推荐