0

我无法抓住我做错了什么。我可以使用硬编码值在 neo4j 控制台上运行查询。

我正在尝试对我的存储库类执行以下查询:

@Query("START user=node({0}) \n" +
        "MATCH (anotherUser) \n" +
        "WHERE NOT (anotherUser<-[:MATCHES]-user) AND NOT user = anotherUser \n" +
        "RETURN anotherUser")
Iterable<User> findMatchesForUser(User user);

查询的结果应该是我作为参数传递的用户之间没有 :MATCHES 边缘的所有用户节点。

我得到以下异常:

SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement START user=node({0}) 
MATCH (anotherUser) 
WHERE NOT (anotherUser<-[:MATCHES]-user) AND NOT user = anotherUser 
RETURN anotherUser; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement START user=node({0}) 
MATCH (anotherUser) 
WHERE NOT (anotherUser<-[:MATCHES]-user) AND NOT user = anotherUser 
RETURN anotherUser; nested exception is `,' expected but `W' found

我也相信它与这里的例子是一致的。任何提示将不胜感激。

4

1 回答 1

0

我能够通过以下查询获得相同的结果:

@Query("START n=node({0}), a=node(*) \n" +
        "MATCH (n)-[r?:MATCHES]->(a) \n" +
        "WHERE has(a.__type__) AND r IS NULL AND a <> n \n" +
        "RETURN a");
Iterable<User> findMatchesForUser(User user);

由于我仍然无法真正理解的原因,我必须添加 has(a. type ) 才能使我的查询工作,否则它会抛出“Could not write JSON: 'type' property not found for NodeImpl#0”试图序列化它。

于 2014-01-15T03:58:12.103 回答