1

I'm trying to implement simple Spring Neo4j repository function with a List parameter:

@Query("MATCH (c:Criterion) WHERE c IN {0} return c")
List<Criterion> getAllCriteria(List<Criterion> criteria);

After execution I'm getting following error:

org.neo4j.cypher.IncomparableValuesException: Don't know how to compare that. Left: Node[513]{name:"Test",description:"Test description"} (NodeProxy); Right: Criterion[id=513,name=Test,description=Test description] (Criterion)

Where I'm wrong ?

alexanoid
  • 24,051
  • 54
  • 210
  • 410

2 Answers2

1

Try this:

@Query("MATCH (c:Criterion) WHERE ID(c) IN {0} return c")
List<Criterion> getAllCriteria(List<Criterion> criteria);

Even though this might work, your query does seems a bit odd, since the returned list would be equal to what you passed in.

cybersam
  • 63,203
  • 6
  • 53
  • 76
  • Unfortunately doesn't work with the error: scala.MatchError: Criterion[id=641,name=Test,description=Test criterion description] (of class com.example.domain.model.decision.Criterion) – alexanoid Feb 25 '15 at 07:57
1

Not sure that lists of parameters are converted. Single entities are converted into their id's.

So if you convert the Criterions into their graph-id's you can do:

@Query("MATCH (c:Criterion) WHERE ID(c) IN {0} return c")
List<Criterion> getAllCriteria(List<Long> criteria);
Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
  • Thanks, works ! One more question, is it possible to automatically convert List to List without changing the Java code ? – alexanoid Feb 25 '15 at 07:52