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的变量对应

上一篇:SQL Server中的事物


下一篇:swift GCD使用指南