Reputation: 5190
Imagine I have a database with one table, this table has only one field named "word" and some other data, imagine also that user can search data by typing contents of this field. I have a lot of words on this table with Spanish accents.
ácido
autobús
camión
If user searches for "acido" or "ácido" words the query will return "ácido" row. How do this with Hibernate?
I'm using Oracle 10g as RDBMS and Hibernate named query.
Thanks in advance
Upvotes: 0
Views: 1916
Reputation: 5190
Finally I'm using Oracle TRANSLATE function, in a named query similar to this:
<query name="queryName">
<![CDATA[
FROM Table
WHERE
upper(TRANSLATE(nivell_1,'ÀàÉÈéèÍíÓóÒòÚú','AaEEeeIiOoOoUu')) LIKE
upper(TRANSLATE(nivell_1,'ÀàÉÈéèÍíÓóÒòÚú','AaEEeeIiOoOoUu'))
]]>
</query>
Upvotes: 0
Reputation: 72930
Hibernate will simply pass the search through to the database. If your database is set up to recognise these differently, then so will Hibernate.
In SQL Server, you can set a collation for the column (or table or database - choice is yours) to make that data accent insensitive. Suspect there are similar mechanisms in other DBMSs, and I would say that will be your best approach.
Upvotes: 2