[英]How to ignore accents in Spring JPA findBy repository?
Lets say we have this repository: 可以说我们有这个存储库:
public interface DeviceTypeRepository extends CrudRepository<DeviceType, Integer>, JpaSpecificationExecutor<DeviceType> {
public Iterable<DeviceType> findByNameContaining(String name);
}
How to obtain the same results by ignoring when user mistypes accents ni search filter? 如何通过忽略用户在搜索过滤器中输入错误的重音来获得相同的结果?
Examples: João | Joao | JOÃO
示例:
João | Joao | JOÃO
João | Joao | JOÃO
João | Joao | JOÃO
, Marcio | Márcio
João | Joao | JOÃO
, Marcio | Márcio
Marcio | Márcio
etc. Marcio | Márcio
等
There is no way to do that within Spring's built-in capabilities. Spring的内置功能无法做到这一点。 You can consider using Elastic Search to do that, there is an article on this subject You Have an Accent .
您可以考虑使用Elastic Search做到这一点,关于此主题的文章You Have a Accent 。
Another way is to not store accent letters in DB and perform mapping before executing SQL request or perform mapping on DB side using custom SQL function - but it's a too cumbersome and fragile solution. 另一种方法是在执行SQL请求之前不将重音字母存储在数据库中并执行映射,或者使用自定义SQL函数在数据库端执行映射-但这是一个麻烦且脆弱的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.