Case insensitive Query with Spring CrudRepository

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.


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);
} 

For those who uses custom JPA query Upper keyword and toUpperCase helps. The following code works for me

 return  entityManager.createQuery("select q from "table " q  where upper(q.applicant)=:applicant")
    .setParameter("applicant",applicant.toUpperCase().trim()).getSingleResult();