我們有一個Parent可以有多個嵌套結構的子結構。Neo4j - Parent - Child heirarchy + Spring
1: Parent p1
child c1
c1.1
c1.2
child c2
c2.1
c2.3
現在使用一個密碼查詢,我需要使用Spring + Neo 4j來獲取整個結構。
型號:
人:
@Relationship(direction = Relationship.OUTGOING, type = "PARENT")
private Person parent;
@Relationship(direction = Relationship.INCOMING, type = "PARENT")
private List<Person> child;
的Cypher查詢: -
MATCH (p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return c1
給我唯一的孩子,但不是他們的下一級子
MATCH (p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return pr
給了我一個嵌套結構這是遞歸的,這是沒用的。
方法: - repository.findOne(personId,2);
我收到了同樣的問題,當我們擴展它的父對象
的一個參考EG的子結構: -
家長P1孩子C1 - >三個對象
1: child-p1 --- it would have a reference to Parent Object p1
2: c1.1 ---
child --it would reference to Child C1 since its parent
3: c1.2
child --it would reference to Child C1 since its parent
理想情況下,它不應該包含子列表中的Parent的任何引用並導致堆棧溢出問題。
我使用SDN 4.0.release做到這一點