使用Spring数据从neo4j获取动态值

时间:2012-11-25 11:51:08

标签: neo4j spring-data spring-data-neo4j

public interface WayPointRepository extends GraphRepository, NamedIndexRepository, RelationshipOperationsRepository {
    @Query( value = "start point=node:waypoints(\"name:{name1}\") return point", elementClass=WayPoint.class, type=QueryType.Cypher ) 
    public List getWayPointByName(@Param("name1") String name);
}

我有一个neo4j数据库,其中存储了一些带有索引“waypoints”的点,我想得到 通过一些点后动态一些点。为此,我创建了占位符{name1},

但是用动态param调用getWayPointByName给我

nested exception is java.lang.RuntimeException: org.apache.lucene.queryParser.ParseException: Cannot parse 'name:{name1}': Encountered " "}" "} "" at line 1, column 11.
Was expecting one of:
    "TO" ...
     ...
     ...
    ] with root cause
org.apache.lucene.queryParser.ParseException: Encountered " "}" "} "" at line 1, column 11.
Was expecting one of:
    "TO" ...
     ...
     ...

at org.apache.lucene.queryParser.QueryParser.generateParseException(QueryParser.java:1818) at org.apache.lucene.queryParser.QueryParser.jj_consume_token(QueryParser.java:1700) at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1507) at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1309) at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1237) at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1226) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)

例外

1 个答案:

答案 0 :(得分:3)

使用

start point=node:waypoints(name={name1}) return point

在字符串中没有参数替换发生。