为了账号安全,请及时绑定邮箱和手机立即绑定

Neo4j 的 Spring Date Repository 和“isEmpty”查询抛出

Neo4j 的 Spring Date Repository 和“isEmpty”查询抛出

慕森卡 2023-05-24 16:10:00
我在 Neo4j 数据库中有以下实体:public class CompetencyEntity {    @GeneratedValue(strategy = UuidStrategy.class)    @Id    private String id;    @Property    private String name;    @Relationship(type = "PARENT_OF", direction = Relationship.OUTGOING)    private List<CompetencyEntity> children;    @Relationship(type = "PARENT_OF", direction = Relationship.INCOMING)            private List<CompetencyEntity> parents;    public void setParentOf(CompetencyEntity competency) {        children.add(competency);    }    public void setNotParentOf(CompetencyEntity competency) {        children.removeIf(comp -> comp.id.equals(competency.id));    }}我想查询数据库,以便它返回所有没有定义父项的实体。我想使用@Repository界面自动生成的查询来完成它。这样做可以让我轻松添加@Depth参数。我的存储库如下:@Repositorypublic interface CompetencyRepository        extends Neo4jRepository<CompetencyEntity, String>, CrudRepository<CompetencyEntity, String> {    Set<CompetencyEntity> findByNameRegex(String name);    @Query("MATCH (n:CompetencyEntity) WHERE NOT (n)<-[:PARENT_OF]-(:CompetencyEntity) RETURN n")    Set<CompetencyEntity> findRootCompetencies();    @Query("MATCH (n:CompetencyEntity) WHERE NOT (:CompetencyEntity)<-[:PARENT_OF]-(n) RETURN n")    Set<CompetencyEntity> findChildrenCompetencies();    Set<CompetencyEntity> findByChildrenEmpty();    Set<CompetencyEntity> findByParentsEmpty();}查询findRootCompetencies确实有效。但是当我尝试findByParentsEmpty()(应该意味着“找到被调用的列表parents为空的实体)方法时,它会抛出以下内容Exception
查看完整描述

1 回答

?
精慕HU

TA贡献1845条经验 获得超8个赞

没有针对关系的派生查找器方法的内置功能。他们都只关注工作(图形)属性。

isEmptyspring Data Neo4j 不支持 special 中的关键字。附录描述了在实现中可能不同的一般 Spring Data 行为。

但是,请查阅特定于商店的文档以获取支持的返回类型的确切列表,因为特定商店可能不支持此处列出的某些类型。

查看完整回答
反对 回复 2023-05-24
  • 1 回答
  • 0 关注
  • 73 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信