diff --git a/src/docbkx/reference/programming-model/repositories.xml b/src/docbkx/reference/programming-model/repositories.xml index 782611bd27..923a53fb66 100644 --- a/src/docbkx/reference/programming-model/repositories.xml +++ b/src/docbkx/reference/programming-model/repositories.xml @@ -180,74 +180,43 @@ - Using these examples and a couple more we can place those queries onto repository methods with @Query and replace values with method parameters, as described - in the ) section. - - - - { - @Query("start n=node({0}) return n") - Movie getMovieFromId(Integer idOfMovie); -}]]> - - - returns the node with id equal to idOfMovie parameter - - - - { - @Query("start movie=node:Movie(title={0}) return movie") - Movie getMovieFromTitle(String movieTitle); -}]]> - - - returns the nodes which are indexed with title equal to movieTitle parameter - - - - + Examples of Cypher queries placed on repository methods with @Query where values are replaced with method parameters, as described + in the <xref linkend="reference:programming-model:annotatedQueries" />) section. + { - @Query("start movie=node:Movie(title={0}) match (movie)<-[:ACTS_IN]-(actor) return actor") - Page getActorsThatActInMovieFromTitle(String movieTitle, PageRequest); -}]]> - - - returns the Actors that have a ACTS_IN relationship to the movie node with the title equal to movieTitle parameter. - (The parenthesis around 'movie' and 'actor' in the match clause are optional.) - - - - { - @Query("start movie=node:({0}) " + - "match (movie)<-[r:RATED]-(user) " + - "where r.stars > {1} " + - "return user") - Iterable getUsersWhoRatedMovieFromTitle(Movie movie, Integer rating); -}]]> - - - returns users who rate a movie (movie parameter) higher than rating (rating parameter) - - - - { - @Query("start movie=node:Movie(title={0}) " + - "match (movie)<-[r:RATED]-(user) " + - "where r.stars > {1} " + - "return user") - Iterable getUsersWhoRatedMovieFromTitle(String movieTitle, Integer rating); -}]]> - - - returns users who rate a movie based on movie title (movieTitle parameter) higher than rating (rating parameter) - - + + // returns the node with id equal to idOfMovie parameter + @Query("start n=node({0}) return n") + Movie getMovieFromId(Integer idOfMovie); + + // returns the nodes which will use index named title equal to movieTitle parameter + // movieTitle String must not contain any spaces, otherwise you will receive a NullPointerException. + @Query("start movie=node:Movie(title={0}) return movie") + Movie getMovieFromTitle(String movieTitle); + + // returns the Actors that have a ACTS_IN relationship to the movie node with the title equal to movieTitle parameter. + // (The parenthesis around 'movie' and 'actor' in the match clause are optional.) + @Query("start movie=node:Movie(title={0}) match (movie)<-[:ACTS_IN]-(actor) return actor") + Page getActorsThatActInMovieFromTitle(String movieTitle, PageRequest); + + // returns users who rate a movie (movie parameter) higher than rating (rating parameter) + @Query("start movie=node:({0}) " + + "match (movie)<-[r:RATED]-(user) " + + "where r.stars > {1} " + + "return user") + Iterable getUsersWhoRatedMovieFromTitle(Movie movie, Integer rating); + + // returns users who rate a movie based on movie title (movieTitle parameter) higher than rating (rating parameter) + @Query("start movie=node:Movie(title={0}) " + + "match (movie)<-[r:RATED]-(user) " + + "where r.stars > {1} " + + "return user") + Iterable getUsersWhoRatedMovieFromTitle(String movieTitle, Integer rating); + } + ]]> + -
Queries derived from finder-method names