Reputation: 81
I am trying to use the Example of Spring JPA to do the search. With the following code, most of it fits the requirements.
public Page<Shop> findShops(Shop condition, Pageable pageable) {
ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(StringMatcher.CONTAINING).withIgnoreCase();
return shopDao.findAll(Example.of(condition, matcher), pageable);
}
In addition, I ONLY need the SHOP with status NOT equals DELETED.
Something like, .withMatcher("status", notEqual())
or maybe .withMatcher("status", contains())
a list.
I am not sure if and how Example Matcher could do such thing. Could anybody help me with this?
Upvotes: 8
Views: 11261
Reputation: 16151
For the one WHERE
clause you dont need QBE. Query from method should be enough:
Page<Shop> findByStatusNot(String status, Pageable page);
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation
Upvotes: 2