Oracle
 sql >> Database >  >> RDS >> Oracle

Come rendere una struttura ad albero in letargo con più tabelle?

Potresti voler avere due colonne nella tabella delle relazioni,

    @ManyToOne(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
@JoinTable(name="Relationship", joinColumns =  @JoinTable(name = "Relationship", joinColumns = @JoinColumn(name = "parent_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "id", referencedColumnName = "id"))@Fetch(FetchMode.SELECT)
 private Node parentNode;
@OneToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
@JoinTable(name = "Relationship", joinColumns = @JoinColumn(name = "id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "parent_id", referencedColumnName = "id"))
@Fetch(FetchMode.SELECT)
 private Set<Node> childNodes;