I am trying to create a Data MongoDB Spring repository method that could be case-insensitive for fields from a given list, that is, functionality similar to the SQL IN statement.
In my repository, I have the 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 also host the repository as a REST resource with @RepositoryRestResource
The first three methods work very well, as I expect. The case is ignored by the search when used findByUsernameIgnoreCase. Users are mapped using the given list of strings in findByUsernameIn.
My problem is that I cannot combine suffixes Inand IgnoreCase. The last two methods also work, but they do not ignore the string case, as I want them to do.
Is there a way to perform case-insensitive Insearches without returning to explicit MongoDB directives @Query?
(tried this with spring -data-mongodb: 1.8.4, spring -data-rest-core: 2.4.4)
source
share