Case insensitive Query with Spring CrudRepository
The following Spring data mongo query works for me. I would prefer to use List
instead of Iterator
public interface DeviceTypeRepository extends CrudRepository<DeviceType,Integer>, JpaSpecificationExecutor<DeviceType> {
List<DeviceType> findByNameIgnoreCase(String name);
}
Exactly as @Peter mentioned in the comment, just add IgnoreCase
:
public interface DeviceTypeRepository
extends CrudRepository<DeviceType, Integer>, JpaSpecificationExecutor<DeviceType> {
public Iterable<DeviceType> findByNameContainingIgnoreCase(String name);
}
See documentation for a list of all supported keywords inside method names.