I searched the forum but didn't find a solution, or the suggestions I found don't work:
I have a website with UTF-8 encoding, I have a search form to enter a query. The database in the back is Postgres8.x with a UTF-8 database. Loading and storing data with German Umlauts works fine, but I have trouble with the search using Restrictions.like.
My database url - I added characterEncoding param:
Code:
<property name="jdbcUrl"><value>jdbc:postgresql://server:5432/dbname?characterEncoding=UTF-8</value></property>
As hibernate property, I added:
Code:
<prop key="hibernate.connection.lc_type">UTF-8</prop>
I want to search using Restrictions.like, so I have:
Code:
.add(Restrictions.like("office.title", this.query.toLowerCase(),MatchMode.ANYWHERE).ignoreCase())
Now I try to search for the word 'südpfalz', which definitely exists in the database, but hibernate doesn't find it. Searching only for 'pfalz' finds the result.
There is something wrong with the umlaut ü. But as far as I can see from my log file, when I output the Criteria, the encoding seems to be alright so far. But the search just doesn't give a result.
This is the logged criteria:
Code:
<Values (DetachableCriteria(CriteriaImpl(com.company.model.realty.LocalizedRealtyData:this[Subcriteria(realty:realty), Subcriteria(realty.office:office)][locale=de, (), (office.title like %südpfalz% or realty.no like %südpfalz% or title like %südpfalz%)])))>
I also updated to the latest postgres-jdbc-driver 8.3.603 and hibernate 3.2.
Last I tried to set the file.encoding to UTF-8 (in the jsp of the search form though - but with that it's set for the entire JVM then), but no difference.
Does anyone know this behaviour?