views:

353

answers:

2

Hi,

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.

Word examples

ácido

autobús

camión

Question

If user searches for "acido" or "ácido" words the query will return "ácido" row. How do this with Hibernate?

Edit

I'm using Oracle 10g as RDBMS and Hibernate named query.

Thanks in advance

+2  A: 

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.

David M
Thanks for your reply, I think you are talking about this Oracle specific mechanism: http://www.rampant-books.com/10g_77.htm
SourceRebels
A: 

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>
SourceRebels