We have a structure where a Parent can have multiple child with nested structure.
1: Parent p1
child c1
c1.1
c1.2
child c2
c2.1
c2.3
Now using one cypher query , I need to get the whole structure using Spring + Neo 4j.
Model:
Person:
@Relationship( direction = Relationship.OUTGOING, type = "PARENT")
private Person parent;
@Relationship( direction = Relationship.INCOMING, type = "PARENT")
private List<Person> child;
Cypher Query :-
MATCH (p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return c1
Gives me only Child but not their next level child
MATCH (p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return pr
Gives me a nested structure which is recursive which is of no use.
Approach :- repository.findOne(personId, 2);
I am getting the same problem as when we expand the child structure it has one reference of parent Object
For e.g:-
Parent p1 child c1 -- > three Object
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
Ideally it should not contain any reference of Parent in Child List and resulting the stack over flow issue.
I am using SDN 4.0.release