GraphRepository find method on 2nd level relationship

174 views Asked by At

I am using spring-data-neo4j-4.2.0.RC1 and neo4j-ogm-core-2.1.0.jar
Have the following domain objects
User -> Role -> Priviledge

public class User extends BaseEntity{
        private String firstName;
        private String lastName;

        @Relationship(type="ROLE")
        private Role role;
}
@NodeEntity
public class Role extends BaseEntity{

    private String name;

    @Relationship(type="PRIVILEDGE")
    private Priviledge priviledge;
}
@NodeEntity
public class Priviledge extends BaseEntity {

    private String name;
}

public interface UserRepository extends GraphRepository<User> {

    User findByRolePriviledgeName(String name);
}

I want to find all users that have a specific priviledge name. The above query worked with JPA and spring repository, but does not return expected result with GraphRepository.
Not sure if this is a bug/not supported or I am doing something wrong

1

There are 1 answers

2
Luanne On

This is not supported in SDN- derived queries support only one level of nesting but yours uses two (Role, then Privilege). You can write a custom @Query for this.