Spring Data Neo4j 4:findByPropertyIsNull无法正常工作 [英] Spring Data Neo4j 4 : findByPropertyIsNull is not working

查看:210
本文介绍了Spring Data Neo4j 4:findByPropertyIsNull无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SDN 4.0并拥有此实体,以提供利益树(父母和子女)

Using SDN 4.0 and having this entity, offering a tree of Interests (Parent and Children)

@NodeEntity
public class Interest {
    @GraphId
    private Long id;
    private Interest parent;    
    private List<Interest> children = new ArrayList<Interest>();
    private String label;
    public Interest(){

    }
    public Interest(Interest parent, String label) {
        super();
        this.parent = parent;       
        this.label = label;
        if (this.parent!=null && !this.parent.getChildren().contains(this))
            getChildren().add(this);
    }
    public List<Interest> getChildren() {
        return children;
    }
    public void setChildren(List<Interest> children) {
        this.children = children;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Interest getParent() {
        return parent;
    }
    public void setParent(Interest parent) {
        this.parent = parent;
    }
    ....  
}

和存储库

public interface InterestRptry extends GraphRepository<Interest>{
    public Page<Interest> findAllByParentIsNull(Pageable pageRequest);//
    public List<Interest> findAllByParentIsNull();//
}

两种语法均未返回任何元素,这是什么问题?

No elements are returned by both syntaxe, what is the problem ?

这可能是因为父级被视为RelationChip而不是Property

This is probably du to the fact that parent is considered as a RelationChip and not a Property

此查询完成工作

MATCH (i:`Interest`) WHERE not(i-[:PARENT]->()) return i

但是会导致异常 Spring Data Neo4j 4:失败从类型java.util.LinkedHashSet<?>转换键入org.springframework.data.domain.Page<?>

推荐答案

SDN 4尚不支持对派生的查找器进行分页. 还不支持isNull.

SDN 4 does not yet support paging on derived finders. isNull is also not supported yet.

解决方法是使用自定义查询.

The workaround is to use a custom query.

这篇关于Spring Data Neo4j 4:findByPropertyIsNull无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆