2

I am using Spring's JPA ExampleMatcher without success.

So far, I have:

    ExampleMatcher matcher = ExampleMatcher.matching()
            .withIgnoreNullValues()
            .withMatcher("surname",  match -> match.contains().ignoreCase());
    Person p = new Person();
    v.setSurname("Sm");

Hoping to match Person objects whose surname field contains the specified substring.

But I consistently get no results.

On looking up the query log, can see why: at tries to match all the other fields too.

How can I get ExampleMatcher to ignore all other fields?

NickJ
  • 9,380
  • 9
  • 51
  • 74

1 Answers1

4

Use .withIgnorePaths() to ignore primitive fields in Person.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • can'g it ignore all paths except those for which matchers are defined? The list of matchers is not constant. – NickJ Mar 02 '18 at 19:59
  • 1
    Could it be that you use primitive fields in `Person`? See https://stackoverflow.com/a/45230155/1602555. – Karol Dowbecki Mar 02 '18 at 20:01
  • Yes, I do have primitive fields. I have swapped them for the primitive wrapper objects. That did the trick! – NickJ Mar 02 '18 at 20:07