【发布时间】:2014-04-29 16:28:11
【问题描述】:
使用 Spring CrudRepository 查询;我想选择具有“名称”属性的“设备类型”实体。但以下查询以区分大小写的方式选择权利。我如何使它不区分大小写。谢谢。
public interface DeviceTypeRepository extends CrudRepository<DeviceType, Integer>, JpaSpecificationExecutor<DeviceType> {
public Iterable<DeviceType> findByNameContaining(String name);
}
【问题讨论】:
-
你试过
public Iterable<DeviceType> findByNameIgnoreCaseContaining(String name);吗? -
如果您对 Query 感兴趣,请试试这个,LIKE
@Query(value= "select dt from DeviceType as dt where lower(dt.name ) like lower(:name)") public Iterable<devicetype> anyMethodNameGoesHere(@Param(name) String name);</devicetype>