I'm using Neo4j Enterprise Edition v4.2.1 and Spring Data Neo4j 6.0.3.
I have the following Query:
MATCH path=(b:BaseHierarchy)-->(n:Group)-[:PARENT_OF*]->(c:Client) WHERE n.code = 'BPCEG' AND c.industry = '1005' WITH collect(path) as paths, b WITH b, reduce(a=, node in reduce(b=,c in [aa in paths | nodes(aa)] | b + c) | case when node in a then a else a + node end) as nodes, reduce(d=, relationship in reduce(e=,f in [dd in paths | relationships(dd)] | e + f) | case when relationship in d then d else d + relationship end) as relationships RETURN b, relationships, nodes;
If I execute it in the Neo4j Browser I get the following graph:
But if I run the same query using
Neo4jTemplate.findOne(query, new HashMap<>(), BaseHierarchyNode.class)
The result only includes the first-level children of the blue node BPCEG.