问题
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