Neamesis :
I'm not very at ease with Oracle. My project uses Java 8, Springboot, JpaRepository and an Oracle DB. I've this query in my repository :
@Query("SELECT lex FROM Lexique lex WHERE UPPER(lex.titre) LIKE UPPER(CONCAT(:lettre,'%')) order by lex.titre ASC ")
List<Lexique> findAllWordsStartingBy(@Param("lettre") String lettre);
When I have the "E" letter, I well retrieve words which start with E. But it's a french project and I also need to retrieve words that start with "é" or "è". And this for all letters which can be associated to special characters.
Does anyone have a solution ?
Arkadiusz Łukasiewicz :
1) Modify nls_sort, and nls_comp
alter session set nls_sort=french_m_ai; --(_m -> multilingual , _ai -> accent insensitive and case insensitive )
alter session set nls_comp=linguistic; -- comparisions base on linguistic rule
Now your query is accent insensitive and case insensitive
SELECT lex FROM Lexique lex WHERE lex.titre LIKE :lettre||'%'
But changing these param will affect others queries.
2) Use nlssort
.Nlssort is returning RAW type and it's not possible to use it with like clause but you can do this workaround.
@Query("SELECT lex FROM Lexique lex WHERE nlssort(substr(lex.titre,1,1), 'NLS_SORT=FRENCH_M_AI') = nlssort(:letter, 'NLS_SORT=FRENCH_M_AI') ", nativeQuery = true)
But I'm not sure about the second solution