在这种情况下如何设计JPA双向重定向?
Class Person{
List<Person> relatedPersons;
Person parentPerson;
}
我尝试下一步,但接收递归。
Class Person{
@OneToMany(mappedBy = "parentPerson")
List<Person> relatedPersons;
@ManyToOne
@JoinTable(joinColumns = {@JoinColumn(name = "related_person_id", referencedColumnName = "id")
Person parentPerson;
}
答案 0 :(得分:0)
试试这个:
Class Person{
@OneToMany (mappedBy = "parentPerson")
List<Person> relatedPersons;
@ManyToOne
@JoinColumn(name="PARENT_PERSON_ID")
Person parentPerson;
}