2

In class Users, I have a field id, firstname, lastname, username, password, enabled.

Enabled field is boolean

When i use do this query by example with spring

Users users = new Users();
users.setId(12);
Example<Users> example = Example.of(users);
Page<Users> pageUsers = userRepository.findAll(example, page);

In the generated query, i see in the where condition, it search on id field and enabled

why it's search on enabled?

robert trudel
  • 5,283
  • 17
  • 72
  • 124

1 Answers1

2

You are using "boolean" primitive type, so your "Example" object has implicitly the "false" value.. you can use "Boolean" type to fix it

Geo
  • 36
  • 1
  • 2
    You can do like that if you don't want to change the type to "Boolean" : Users users = new Users(); users.setId(12); ExampleMatcher exampleMatcher = ExampleMatcher.matching().withIgnorePaths("enabled"); Example example = Example.of(users, exampleMatcher); Page pageUsers = userRepository.findAll(example, page); – Geo Sep 13 '17 at 09:12