GraphRepository find method on 2nd level relationship

余生颓废 提交于 2019-12-12 04:23:11

问题


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:


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.



来源:https://stackoverflow.com/questions/41504620/graphrepository-find-method-on-2nd-level-relationship

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