我认为忽略大小写
查询的语法是:
findByFieldIgnoreCase(Object field)
集合
查询的语法是
findByFieldIn(List<Object> fields)
忽略案例集合
查询的语法为:
findByFieldIgnoreCaseIn(List<Object> fields)
但这似乎不起作用(它仍然区分大小写)。
想法?
编辑:
它也不是findByFieldInIgnoreCase
。
最佳答案
Spring Data MongoDB Reference Documentation指出:
The method parser supports setting an IgnoreCase flag for individual properties (for example, findByLastnameIgnoreCase(…)) or for all properties of a type that support ignoring case (usually String instances, for example, findByLastnameAndFirstnameAllIgnoreCase(…)). Whether ignoring cases is supported may vary by store, so consult the relevant sections in the reference documentation for the store-specific query method.
supported keywords for query methods的表格没有明确提及 InIgnoreCase 或 IgnoreCaseIn 关键字。
至于其他unsupported keywords ,您可以在 Spring Data MongoDB JIRA 上提出功能请求.
同时,要让您的代码运行,您可以使用 Query 实现您自己的 findByFieldInIgnoreCase 的 findByFieldIgnoreCaseIn注释或Querydsl 。我在另一个 post 中为类似案例提供了几种可能的解决方案.
关于java - Spring CrudRepository - 在集合中查找忽略大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37022436/