-->
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.  [ 4 posts ] 
Author Message
 Post subject: session.createQuery ERROR
PostPosted: Thu Mar 17, 2005 8:48 am 
Newbie

Joined: Mon Oct 04, 2004 8:53 am
Posts: 10
Hibernate version: 3.0rc1

Name and version of the database you are using: MySQL 4.0.21


Hibernate throws a QueryException when I use letters like "á, é, ..."

List result = sess.createQuery("FROM Bem b WHERE b.plqta ='máx' AND b.situo=2 ORDER BY b.plqta").list();

org.hibernate.QueryException: expecting ''', found 'á' [FROM com.maxiti.data.Bem b WHERE b.plqta ='máx' AND b.situo=2 ORDER BY b.plqta]

WHAT IS WRONG ?

In Hibernate 2.1.7, using session.find, this error does not occur.

Thanks,

Glauber Andrade


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 9:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
report it in the jira.

workaround (and a much better strategy in general): use parameters.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 9:18 am 
Newbie

Joined: Mon Oct 04, 2004 8:53 am
Posts: 10
use parameters ?!?!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 9:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Code:
List result = sess.createQuery("FROM Bem b WHERE b.plqta =:qta AND b.situo=:situo ORDER BY b.plqta").setString("qta", "máx").setLong("situo", 2).list();


works much better. More efficient and safer.

and then go read the hibernate documentation about queries and parameters.

/max

_________________
Max
Don't forget to rate


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