NaN
NaN

Reputation: 9104

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, Marcio | Márcio etc.

Upvotes: 3

Views: 3425

Answers (1)

V&#252;sal
V&#252;sal

Reputation: 2706

There is no way to do that within Spring's built-in capabilities. You can consider using Elastic Search to do that, there is an article on this subject You Have an 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.

Upvotes: 2

Related Questions