简体   繁体   中英

Spring data query for finding nodes which don't have a specific relationship

I've got a node:

    @NodeEntity
    public class Category {

        @GraphId
        private Long id;
        private String title;
        @Relationship(type = "PARENT")
        private Category parent;
    }

Is there a "findBy..." method, which will return all the categories which don't have a parent?

I've tried findByParentIsNull(), findByParentIdIsNull(), etc. These didn't work for me.

This feature is not supported for the moment. You have to use a cypher query like :

@Query("MATCH (u:User) WHERE NOT (u)-[:PARENT]-(:Category) RETURN u")

If you use it frequently and think it can be useful, feel free to open a feature request for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM