![](/img/trans.png)
[英]how to use spring data example matcher for list attribute - query issue
[英]How to use Spring Data JPA example matcher with additional conditions
我正在尝试使用Spring JPA的示例来进行搜索。 使用以下代码,大部分代码符合要求。
public Page<Shop> findShops(Shop condition, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(StringMatcher.CONTAINING).withIgnoreCase();
return shopDao.findAll(Example.of(condition, matcher), pageable);
}
另外,我只需要状态NOT等于DELETED的SHOP。 类似于.withMatcher("status", notEqual())
或者.withMatcher("status", contains())
列表。
我不确定示例匹配器是否以及如何做这样的事情。 有人可以帮帮我吗?
对于一个WHERE
子句,您不需要QBE。 从方法查询应该足够了:
Page<Shop> findByStatusNot(String status, Pageable page);
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.