Neo4j——父子继承权+;春天
我们有一个结构,其中一个父级可以有多个嵌套结构的子级Neo4j——父子继承权+;春天,neo4j,cypher,spring-data-neo4j-4,neo4j-ogm,Neo4j,Cypher,Spring Data Neo4j 4,Neo4j Ogm,我们有一个结构,其中一个父级可以有多个嵌套结构的子级 1: Parent p1 child c1 c1.1 c1.2 child c2 c2.1 c2.3 现在使用一个cypher查询,我需要使用Spring+neo4j获得整个结构 型号: 人: @Relationship( direction = Relationship.OUTGOING, type = "PARENT") pri
1: Parent p1
child c1
c1.1
c1.2
child c2
c2.1
c2.3
现在使用一个cypher查询,我需要使用Spring+neo4j获得整个结构
型号:
人:
@Relationship( direction = Relationship.OUTGOING, type = "PARENT")
private Person parent;
@Relationship( direction = Relationship.INCOMING, type = "PARENT")
private List<Person> child;
理想情况下,它不应该在子列表中包含任何对父对象的引用,从而导致堆栈溢出问题
我使用的是SDN 4.0。发布一种方法是加载具有自定义深度的实体,如下所示-
repository.findOne(personId, 2);
其中2是深度
如果您使用的是SDN4.0,那么您的Cypher查询在这种情况下不会有多大用处,因为实体不会从查询结果映射
如果使用SDN 4.1,则可以从路径返回所有节点和关系,并且域实体将正确映射。
例如:
MATCH path=(p:Person{name:“john”})
MATCH (p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return pr
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
repository.findOne(personId, 2);
MATCH path=(p:Person {name:"john"})<-[pr:PARENT*..2]-(p1:Person) return p as person, nodes(path),rels(path)