Horje
spring jpa tree structure Code Example
spring jpa tree structure
@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;
}
spring jpa tree structure
@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;
}




Java

Related
jpa tree structure Code Example jpa tree structure Code Example
java create list with one element Code Example java create list with one element Code Example
how to build a java main menu Code Example how to build a java main menu Code Example
javax notblank not working Code Example javax notblank not working Code Example
java localdate zoneid example Code Example java localdate zoneid example Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8