0

Is there any way that ExampleMatcher can filter string of "",not null? Thank u!

My code:

    public Page<Address> findAllByPage(Address address,Pageable pageable){
        ExampleMatcher matcher = ExampleMatcher.matching().withIgnoreNullValues();
        return addressRepository.findAll(Example.of(address, matcher), pageable);
    }

Value of address:

{
  "id": null,
  "country": "",
  "province": "",
  "city": "",
  "district": "",
  "street": "",
  "detailAddress": ""
}

The generated sql:

Hibernate: select address0_.id as id1_0_, address0_.city as city2_0_, address0_.country as country3_0_, address0_.detail_address as detail_a4_0_, address0_.district as district5_0_, address0_.province as province6_0_, address0_.street as street7_0_ from address address0_ where address0_.city=? and address0_.district=? and address0_.detail_address=? and address0_.street=? and address0_.province=? and address0_.country=? 

But i want something like this:

Hibernate: select address0_.id as id1_0_, address0_.city as city2_0_, address0_.country as country3_0_, address0_.detail_address as detail_a4_0_, address0_.district as district5_0_, address0_.province as province6_0_, address0_.street as street7_0_ from address address0_ 
wae
  • 45
  • 7

0 Answers0