Case insensitive Query with Spring CrudRepository

后端 未结 4 1811
Happy的楠姐
Happy的楠姐 2020-12-04 18:44

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. Ho

4条回答
  •  抹茶落季
    2020-12-04 19:29

    In my case adding IgnoreCase did not work at all.

    I found that it is possible to provide options for the regular expression ,as well:

    @Query(value = "{'title': {$regex : ?0, $options: 'i'}}")
    Foo findByTitleRegex(String regexString);
    

    The i option makes the query case-insensitive.

提交回复
热议问题