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