假设有两个节点实体:
public class Account extends BaseEntity
{
...
@Fetch
@RelatedTo(type = "HAS_ROLE")
private Set<Role> roles = Sets.newHashSet();
...
}
public class Role extends BaseEntity
{
...
}
在我的存储库中,我有一个查询应该按给定角色获取所有帐户:
public interface AccountRepository extends GraphRepository<Account>
{
@Query("START account=node:Account(0) MATCH account-[:HAS_ROLE]->({0}) return account")
Iterable<Account> findByRole(Role role);
}
但是此查询不起作用,当我在测试用例中使用此方法时,出现以下错误:
org.springframework.dao.InvalidDataAccessResourceUsageException: 执行语句出错 START account=node:Account(0) MATCH account-[:HAS_ROLE]->({0}) return account; 嵌套异常是 org.springframework.dao.InvalidDataAccessResourceUsageException: Error execution statement START account=node:Account(0) MATCH account-[:HAS_ROLE]->({0}) return account; 嵌套异常是预期的字符串
看来,我的查询有问题,但我不知道是什么,也无法弄清楚......有人可以提供帮助吗?