@NodeEntity
public class User {
private Long id,
private String email,
@Relationship(type = "hasOne", direction = Relationship.OUTGOING)
private Profile profile
}
@NodeEntity
public class Profile {
private Long id;
private String firstName
}我只需要在email = "abc"和firstName="xyz"的位置加载user对象。
我使用的是spring-data-new4j 4.2.3版本。
如何有效地在这个查询上使用ogm过滤器(我不需要原生查询)?
发布于 2017-06-20 18:00:23
您可以使用Spring Data derived finders。
在您的UserRepository中创建一个如下所示的方法:
User findByEmailAndProfileFirstName(String email, String firstName);请注意,在派生查找器中只能使用1层嵌套。
发布于 2019-01-19 00:42:14
您可以使用嵌套过滤器,如下所示:Filter emailFilter = new Filter("email", ComparisonOperator.EQUALS, "krishna@abc.in"); Filter firstNameFilter = new Filter("firstName", ComparisonOperator.EQUALS, "krishna"); firstNameFilter.setNestedPath({ new Filter.NestedPathSegment("profile", Profile.class); }); return session.loadAll(User.class, emailFilter.and(firstNameFilter));
https://stackoverflow.com/questions/44519895
复制相似问题