23

How do I make findByIn search using IgnoreCase of <Field>? I tried to use findByNameIgnoreCaseIn and findByNameInIgnoreCase with no result. DB is Postgresql.

@Repository
public interface UserRepository {
    List<User> findByNameIgnoreCaseIn(List<String> userNames);
}
Daria Bulanova
  • 547
  • 1
  • 5
  • 16

2 Answers2

21

Try something like this:

List<User> findByNameInIgnoreCase(List<String> userNames);
Laurel
  • 5,965
  • 14
  • 31
  • 57
Sumeet Tiwari
  • 343
  • 2
  • 11
14

As I understood IgnoreCase is not supported with In key, so I changed code this way:

@Repository
public interface UserRepository {
    @Query("select user from SysUser user where upper(name) in :userNames")
    List<SysUser> findByNameIgnoreCaseIn(@Param("userNames") List<String> userNames);
}

and previously upper case userNames values.

Daria Bulanova
  • 547
  • 1
  • 5
  • 16