Spring Data Neo4j 4 : findByPropertyIsNull is not working

 ̄綄美尐妖づ 提交于 2019-12-12 04:16:15

问题


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;
    }
    ....  
}

and the repository

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 ?

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

This query do the job

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

but it cause an exception Spring Data Neo4j 4 : Failed to convert from type java.util.LinkedHashSet<?> to type org.springframework.data.domain.Page<?>


回答1:


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

The workaround is to use a custom query.



来源:https://stackoverflow.com/questions/34317586/spring-data-neo4j-4-findbypropertyisnull-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!