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

我在 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参数。


我的存储库如下:


@Repository

public 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


慕森卡
浏览 75回答 1
1回答

精慕HU

没有针对关系的派生查找器方法的内置功能。他们都只关注工作(图形)属性。isEmptyspring Data Neo4j 不支持 special 中的关键字。附录描述了在实现中可能不同的一般 Spring Data 行为。但是,请查阅特定于商店的文档以获取支持的返回类型的确切列表,因为特定商店可能不支持此处列出的某些类型。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java