OGM 始终为 0 的自定义 Cypher 查询的深度?

Depth in custom Cypher queries with OGM always 0?

我目前正在为一个用例评估 OGM / Spring Data Neo4j,并遇到了以下问题:

当通过 Spring Data @Query 注释或直接通过 Neo4j Session 执行自定义 Cypher 查询时,结果仅包含直接查询的节点,而不包含相关节点(结果节点对象中的关系是 null)。 IE。这些查询的深度似乎是 0 而不是 1,正如我从文档中所期望的那样。

如何通过 OGM 或深度为 1 的 Spring Data Neo4j 执行自定义 Cypher 查询?

默认深度 1 指的是 findOne/findAll/.. 来自存储库和派生查找器的方法。

文档中关于自定义查询的内容如下:

In the current version, custom queries do not support paging, sorting or a custom depth. In addition, it does not support mapping a path to domain entities, as such, a path should not be returned from a Cypher query. Instead, return nodes and relationships to have them mapped to domain entities.

http://docs.spring.io/spring-data/data-neo4j/docs/current/reference/html/#reference:session:loading-entities:cypher-queries

例如,当您有一个查询时

MATCH (n:MyLabel)-[r]-(n2)
WHERE ... // some condition
RETURN n,r,n2

在 RETURN 子句中列出您要映射到对象的所有 nodes/relationships。