NickJ
NickJ

Reputation: 9559

Spring JPA Query by Example returns no results

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?

Upvotes: 2

Views: 1274

Answers (1)

Karol Dowbecki
Karol Dowbecki

Reputation: 44932

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

Upvotes: 4

Related Questions