From 25f64c1f53fd63da8103a3057b67e8de829be2c8 Mon Sep 17 00:00:00 2001 From: Gerrit Meier Date: Thu, 12 Oct 2017 15:47:26 +0200 Subject: [PATCH] DATAGRAPH-791 - add documentation for named queries support. --- src/main/asciidoc/reference/neo4j-repositories.adoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/asciidoc/reference/neo4j-repositories.adoc b/src/main/asciidoc/reference/neo4j-repositories.adoc index 241ec4872..ea7ae56ac 100644 --- a/src/main/asciidoc/reference/neo4j-repositories.adoc +++ b/src/main/asciidoc/reference/neo4j-repositories.adoc @@ -155,6 +155,14 @@ Additionally, `@Query` does not support mapping a path to domain entities, as su Instead, return nodes and relationships to have them mapped to domain entities. ==== +=== Named queries + +Sometimes it makes sense to extract e.g. a long query. +Spring Data Neo4j will look in the `META-INF/neo4j-named-queries.properties` file to find named queries. +If you provide a query property like `User.findByQuery=MATCH (e) WHERE e.name={name} RETURN e` you can refer to this method by providing a finder method in your repository. +The repository has to support the given entity type (in this example `User`) and the method has to be named as the defined one (`findByQuery`). +As you can see in the example it is possible to parameterize the query. + === Query results Typical results for queries are `Iterable`, `Iterable>` or simply `Type`.