-->
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.  [ 6 posts ] 
Author Message
 Post subject: HQL doesn't support chinese character
PostPosted: Fri Apr 22, 2005 4:36 am 
Newbie

Joined: Fri Apr 22, 2005 4:09 am
Posts: 6
Hibernate version:3.0.1


Name and version of the database you are using:oracle


Following is my code:

....
String hsql = "from Customer c where c.name='测试' ";
Query query = session.createQuery(hsql);
query.list();
....

when excuting,no exception thrown,but no query result return (they should return based the condition c.name='测试')

this is the sql hibernate generate for the hsql:
select customer0_.CUSTOMER_NO as CUSTOMER1_, customer0_.CODE as CODE9_, customer0_.NAME as NAME9_, customer0_.STATUS as STATUS9_, customer0_.LAST_OPE RATOR_NO as LAST5_9_ from CUSTOMER customer0_ where (customer0_.NAME='????')

the chinese characters '测试' in hsql become '????' in sql.

by the way, it's run well in the hibernate2 version.

Thank for you help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 5:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm - put it as a bug in the jira since the parser should not try and convert it.

A better way to run you query though is to use parameters.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 5:42 am 
Newbie

Joined: Fri Apr 22, 2005 4:09 am
Posts: 6
i can not use parameter..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 6:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why not ? parameters is much more safe to use and you would get proper handling of your unicode characters no matter what happens.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 7:58 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try UNICODE escapes, this query depends on your text editor and compiler encoding settings.


Top
 Profile  
 
 Post subject: there is no this problem on weblogic
PostPosted: Tue Apr 26, 2005 12:20 am 
Newbie

Joined: Sat Feb 21, 2004 2:22 am
Posts: 1
It occured when I deploy my app on resin, but when I deploy it on weblogic the problem disappears


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.