Hibernate version: 3.1rc3 And I am using Chinese characters with gb2312 encoding
My problem is : Using hql query a column with Chinese characters, If I hard code the Chinese into the query string, it works fine. But when I do it using
parameter binding, I cannot get any results(No error or exception reported),
Even when I do it using criteria, I still cannot get the result.
Since, 1. When I hard code it in the query string, It goes fine, so my character encoding and jdbc connection is of course set properly.
2. With paramter binding hql or criteira, if I donot use Chinese characters, it works fine. Seems hql and criteira do works.
SO what may the problem lies?
The sample code like follows:
Session.createQuery(" from table1 where table1.name='问题'"); -Works
Session.createQuery("from table1 where table1.name=:
name").setString("name","问题");---No result returned
Session.createCriteira(table1.class).addCriteria(Expression.eq("name","问题")); ------No result returned
Session.createQuery("from table1 where table1.name=:
name").setString("name","problem");---Works
Session.createCriteira(table1.class).addCriteria(Expression.eq("name","problem")); ------Works
Name and version of the database you are using: Mysql 4.7
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|