我正在寻找如何在我的Branch对象中解决递归和双向一对一体关系:
@Entity
@Table("BRANCH")
public class Branch {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
private String name;
@OneToOne
@JoinColumn(name = "id")
private Branch parent;
@OneToOne(mappedBy = "parent")
@JoinColumn(name = "parent_id")
private Branch child;
//Getters and Setters
}
这是一种被接受的模式吗?
慕神8447489
相关分类