“JPA -Baumstruktur” Code-Antworten

JPA -Baumstruktur

@Entity
@Table(name = "node")
public class Node {

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "name")
    private String name;

    @Column(name = "parent_id")
    private String parentId;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    private Set<Node> childNodes;
}
Hard Rock

JPA -Baumstruktur

@Entity
@Table(name = "node")
public class Node {

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "name")
    private String name;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    private Node parentNode;

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "parentNode")
    private Set<Node> childNodes;
}
Hard Rock

Ähnliche Antworten wie “JPA -Baumstruktur”

Fragen ähnlich wie “JPA -Baumstruktur”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen