使用Spring CrudRepository的不区分大小写的查询 [英] Case insensitive Query with Spring CrudRepository
本文介绍了使用Spring CrudRepository的不区分大小写的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Spring CrudRepository查询;我想选择具有其名称"属性的"DeviceType"实体.但是下面的查询以区分大小写的方式选择权利.我如何使其不区分大小写.谢谢.
With Spring CrudRepository Query; I want to select "DeviceType" entities with it's "name" property. But following query select the entitles on case sensitive manner. How I make it case insensitive way. Thanks.
public interface DeviceTypeRepository extends CrudRepository<DeviceType, Integer>, JpaSpecificationExecutor<DeviceType> {
public Iterable<DeviceType> findByNameContaining(String name);
}
推荐答案
与注释中提到的@Peter完全一样,只需添加IgnoreCase
:
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.
这篇关于使用Spring CrudRepository的不区分大小写的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文