jpa OneToMany

Project, project_id

@OneToMany(mappedBy = "project")
    private Set<Ap> apSet =new HashSet<Ap>();

Ap, ap_id

@ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn( name = "project_id",nullable = false)
    private Project project;

注意不要有cascade之类的,会冲突
ManyToOne里的name要跟OneToMany的对象的id对应
OneToMany里的mappedBy要跟ManyToOne的变量对应

posted @ 2016-10-13 11:43  蚂蚁都督  阅读(181)  评论(0编辑  收藏  举报