我已经在 Neo4j Web 界面中测试了我的查询,现在我想将它添加到我的 Java 程序中。我已经尝试过了(在一个名为 Track 的 @NodeEntity 类中):
@Query("START n=({self}) MATCH (n)-->(x)<--(y) RETURN y")
private Iterable<Track> alternativeTracks;
还有这个(在 GraphRepository 扩展接口中):
@Query("START n={track} MATCH (n)-->(x)<--(y) RETURN y")
public Iterable<Track> findAlternativeTracks(@Param("track") Track track);
还有位置版本:
@Query("START n={0} MATCH (n)-->(x)<--(y) RETURN y")
public Iterable<Track> findAlternativeTracks(Track track);
但每次我得到这个异常并跟踪:
Exception in thread "main" org.neo4j.rest.graphdb.RestResultException: expected either node or relationship here
"START n=({self}) MATCH (n)-->(x)<--(y) RETURN y"
^ at
SyntaxException
org.neo4j.cypher.internal.parser.v1_8.CypherParserImpl.parse(CypherParserImpl.scala:45)
org.neo4j.cypher.CypherParser.parse(CypherParser.scala:42)
org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)
org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:67)
org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:37)
org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:67)
org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:59)
org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:63)
org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)
org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:67)
java.lang.reflect.Method.invoke(Method.java:597)
将“self”替换为“track”或“0”,具体取决于我正在尝试的版本。
我一遍又一遍地阅读了文档和示例,但我似乎无法弄清楚我在这里缺少什么。任何人都可以启发我吗?
(我在 spring-data-neo4j 版本 2.2.1.RELEASE 上)