javaspring引导说明save dao

jjjwad0x  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(235)

我在前面有一个用angular编写的应用程序,在后面有一个用mysql(phpmyadmin)编写的javaspring引导程序。
我不明白为什么当我更新它时,它并不总是起作用。如果我换了“公司”就行了,但如果我只换了“环境科技”就不行了。

@Entity
@Table(name="experiences")
@NamedQuery(name="Experience.findAll", query="SELECT e FROM Experience e")
public class Experience implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    private String company;

    private String date;

    @Column(name="env_tech")
    private String envTech;

    //bi-directional many-to-one association to Resume
    @JsonIgnore
    @ManyToOne
    @JoinColumn(name="resume")
    private Resume resumeBean;

    //bi-directional many-to-one association to Mission
    @OneToMany(mappedBy="experience")
    private List<Mission> missions;

@Entity
@Table(name="resumes")
@NamedQuery(name="Resume.findAll", query="SELECT r FROM Resume r")
public class Resume implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;

    //bi-directional many-to-one association to Paragraph
    @OneToMany(mappedBy="resumeBean")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Paragraph> paragraphs;

    //bi-directional many-to-one association to Experience
    @OneToMany(mappedBy="resumeBean")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Experience> experiences;

    //bi-directional many-to-one association to Skill
    @OneToMany(mappedBy="resumeBean")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Skill> solution;

    //bi-directional many-to-one association to Condition
    @ManyToOne
    @JoinColumn(name="condition")
    private Condition condition;

    //bi-directional many-to-one association to Profil
    @ManyToOne
    @JoinColumn(name="profil")
    private Profil profil;
@PutMapping(value = "/allresumes/{id}")
    public boolean updateResume(@PathVariable int id, @RequestBody Resume resume) {
    ...
    resume.getExperiences().forEach(experience -> {
            expUpdt =expService.getExperienceById(experience.getId());
            if (expUpdt == null) {
            ...
            } else {
                /*
                public void setResumeBean(Resume resumeBean) {
                        this.resumeBean = resumeBean;
                    }
                */
                experience.setResumeBean(resume);
                experience.getMissions().forEach(mission -> {
                    Mission missionUpt = missionService.getMissionByProject(mission.getProject());
                    if(missionUpt==null){
                        missionUpt = mission;
                        missionUpt.setExperience(experience);
                        logger.info("NULL MISSION" +missionUpt);
                        missionService.saveMission(missionUpt);
                    }else{
                        logger.info("NOT NULL MISSION" +mission);
                        mission.setExperience(experience);
                        missionService.updateMission(mission);
                    }

                });
            }

    }
}

我不知道如果不给你全部的话,我该给你什么样的代码
更新来自updateresume。简历是一个对象,满足了很多列表上甚至有过的经历
我不明白为什么和什么时候“experience.getmissions().foreach(mission->{…}”进行保存,如果只编辑了“envtech”,则不保存。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题