I've got a database with names in it. These names sometimes contain non ascii characters e.g. González. I've got the collation settings such that if I search for WHERE LastName LIKE '%Gonzalez%'
I get González's record back. In Management Studio I can search for both WHERE LastName LIKE '%Gonzalez%'
and WHERE LastName LIKE '%González%'
and both return the correct value. However when I use JPA / Hibernate the query that gets sent to the database clearly doesn't represent the á
character correctly as I get 0 results.
When utilising the show_sql attribute I can see the actual query is fine, and If I copy and paste that query and replace the ?
characters with '%González%'
I get the correct results. Likewise if I search for Gonzalez through the web interface I get results, so I'm confident it's the á
that is causing me problems, and it's only JPA / Hibernate that is causing the issue. (Having said that the issue could be the AJAX submission to the servlet that is causing the issue, but the parameter is sent as ?LastName=Gonz%C3%A1lez
which I think is right?)
So if it's JPA / Hibernate how do I diagnose / fix the issue?