I'm trying to create a Spring Data MongoDB repository method that could perform case insensitive search for fields from a given list, that is functionality similar to SQL 'IN' operator.
In my repository I have following methods:
User findByUsername(@Param("username") String username);
User findByUsernameIgnoreCase(@Param("username") String username);
Page<User> findByUsernameIn(@Param("username") List<String> username, Pageable pageable);
Page<User> findByUsernameIgnoreCaseIn(@Param("username") List<String> username, Pageable pageable);
Page<User> findByUsernameInIgnoreCase(@Param("username") List<String> username, Pageable pageable);
Page<User> findByUsernameInAllIgnoreCase(@Param("username") List<String> username, Pageable pageable);
I'm also exposing repository as REST resource using @RepositoryRestResource
The first three methods work very well as I expect. The case gets ignored by search when using findByUsernameIgnoreCase
. The users are correclty found using the given string list in findByUsernameIn
.
My problem is that I cannot combine In
and IgnoreCase
suffixes.
The last two methods also work, but they don't ignore case of the string as I want them to do.
Is there a way to perform case insensitive IN
search not falling back to explicitly specifying the MongoDB @Query
?
(Tried that with spring-data-mongodb:1.8.4, spring-data-rest-core:2.4.4)