blueboy
blueboy

Reputation: 64

how to pass relationship query parameter in spring data neo4j

returns error with below annoation.

@Query(value ="MATCH (n:Phone {phoneId:{0}})-[f:calling*0..{1}]-(m) OPTIONAL MATCH (m)-[r]-() return m,r")  
List<QueryPOJO> graph(String name,int level);

Description: Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}") (line 1, column 45 (offset: 44))

we need a elegant method to resolve this problem instead of write many interfaces.

   @Query(value ="MATCH (n:Phone {phoneId:{0}})-[f:calling*0..2]-(m) 
   OPTIONAL MATCH (m)-[r]-() return m,r")  
   List<QueryPOJO> grapht_2(String name,int level);

   @Query(value ="MATCH (n:Phone {phoneId:{0}})-[f:calling*0..3]-(m) 
   OPTIONAL MATCH (m)-[r]-() return m,r")  
   List<QueryPOJO> grapht_3(String name,int level);

cypher cannot resolve level relationship problem.

   MATCH (n:Person {name:'AAA'})-[f]-(m) where type(f)="Follow" OPTIONAL MATCH (m)-[r]-() return m,r

Upvotes: 0

Views: 917

Answers (2)

vic zhong
vic zhong

Reputation: 1

Cypher doesn't support limits on relationships like you did.You can try to limit the length of a path using function length() like this:

MATCH p=(n:Phone {phoneId:{0}})-[f:calling]-(m) OPTIONAL MATCH (m)-[r]-() where length(p)<{1} return m,r

Function length() gets the length of a path. Referring this,#Path Functions.

Upvotes: 0

Eric Spiegelberg
Eric Spiegelberg

Reputation: 622

You may need to resort to "manually" constructing the Cypher statement as a String and executing it through the Session, which allows execution of arbitrary Cypher queries via its query, queryForObject and queryForObjects methods.

Upvotes: 1

Related Questions