我有以下 yml 和实体。
每次我通过 Fixtures.loadModels() 加载 yml 时,每个实体都会被持久化,但 VSCode 上的 vsCat_id 外键始终为空,并且关系不会持久化。
我在这里想念什么?
yml:
VSCode(VS960):
vsCode: VS960
description: blabla
VSCategory(dvs1):
name: Category 1
vsCodes:
- VSA960
- VSA961
public class VSCode extends GenericModel {
@Id
public String vsCode;
public String description;
@ManyToOne
public VSCategory vsCat;
public VSCode(String code, String description) {
this.vsCode = code;
this.description = description;
}
}
@Entity
public class VSCategory extends Model {
public String name;
@OneToMany(mappedBy="vsCat")
public Set<VSCode> vsCodes;
public VSCategory(String name){
this.name = name;
this.vsCodes = new HashSet();
}
}