-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate hql parameter binding problem
PostPosted: Mon Nov 28, 2005 8:27 am 
Newbie

Joined: Mon Nov 28, 2005 8:07 am
Posts: 4
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:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 10:50 am 
Newbie

Joined: Mon Nov 28, 2005 8:07 am
Posts: 4
Ok, I think I have finally done.

I don't know which one is the fact.
I updated mysql from 4.1 to 5.0
And
I have set all character set to utf8 Not gb2312


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.