我们有一个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做到这一点