How to use Spring Example JPA data mapping with additional conditions

I am trying to use Spring JPA example to do a search. With the following code, most of them meet 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);
    }

Also, I ONLY need a STORE with the status NOT equals DELETED. Something like .withMatcher("status", notEqual()) or maybe a .withMatcher("status", contains())list.

I'm not sure how and as an example Matcher could do such a thing. Can someone help me with this?

+4
source share
1 answer

For one sentence WHEREyou do not need QBE. The request from the 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

0

Source: https://habr.com/ru/post/1656058/


All Articles