使用 Cypher,通过以逗号分隔的方式列出多个节点来选择多个节点:
START n=node(1, 2, 3) RETURN n
http://docs.neo4j.org/chunked/milestone/query-start.html#start-multiple-nodes-by-id
我想将它与 Spring Data @Query 一起使用,但它不起作用:
@Query("start person=node({0}) match (person)-[:has_friends]->(friend) return friend")
private Iterable<Person> friends(Iterable<Person> persons);
编辑: 这是堆栈跟踪:
java.lang.ClassCastException: Person cannot be cast to org.neo4j.graphdb.Node
at org.neo4j.kernel.impl.traversal.AsOneStartBranch.toBranches(AsOneStartBranch.java:65)
at org.neo4j.kernel.impl.traversal.AsOneStartBranch.<init>(AsOneStartBranch.java:59)
at org.neo4j.kernel.impl.traversal.BidirectionalTraverserIterator.<init>(BidirectionalTraverserIterator.java:81)
at org.neo4j.kernel.impl.traversal.BidirectionalTraverserImpl.instantiateIterator(BidirectionalTraverserImpl.java:44)
at org.neo4j.kernel.impl.traversal.AbstractTraverser.iterator(AbstractTraverser.java:83)
at org.neo4j.cypher.internal.pipes.matching.BidirectionalTraversalMatcher.findMatchingPaths(BidirectionalTraversalMatcher.scala:73)
at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$createResults$1.apply(TraversalMatchPipe.scala:32)
at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$createResults$1.apply(TraversalMatchPipe.scala:29)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:138)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.JavaConversions$IteratorWrapper.hasNext(JavaConversions.scala:562)
at org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)
任何想法?