Search code examples
neo4jspring-data-neo4jspring-data-neo4j-4neo4j-ogm

Neo4j Session query doesn't work with @QueryResult


When I try to use the Session method with a parametrised object of type @QueryResult, the method can't hydrate the resulting list:

<T> Iterable<T> query(Class<T> objectType, String cypher, Map<String, ?> parameters);

Is this normal?


Solution

  • As @QueryResult is a Spring Data Neo4j (SDN) concept, it is not able to work with the Neo4j OGM Session functionality.

    What you can do instead is just add the query you want to a repository method of SDN with the @Query annotation and have it return a @QueryResult with the list embedded inside it. Something like:

    @Query("MATCH ... ")
    CustomQueryResult myCustomQuery(@Param("aParam") String param);