-->
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.  [ 1 post ] 
Author Message
 Post subject: single quote in HQL is not being parsed properly
PostPosted: Wed Sep 22, 2004 10:12 am 
Newbie

Joined: Wed Sep 22, 2004 9:17 am
Posts: 1
Hibernate version: 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():
List list = session.find("select event from Event event where event.eventName like \"%vikas's%\"");
Full stack trace of any exception that occurs:
19:24:52,750 DEBUG [QueryTranslator] HQL: select event from com.xxx.Event event where event.eventName like "%vikas's%"
19:24:52,750 DEBUG [QueryTranslator] SQL: select event0_.ID as ID, event0_.DESCRIPTION as DESCRIPT4_,event0_.EVENTNAME as EVENTNAME, from EVENT event0_ where (event0_.EVENTNAME like "%vikas )
19:24:52,750 DEBUG [BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
19:24:52,750 DEBUG [SQL] select event0_.ID as ID, event0_.DESCRIPTION as DESCRIPT4_, event0_.EVENTNAME as EVENTNAME from EVENT event0_ where (event0_.EVENTNAME like "%vikas )
19:24:52,750 INFO [STDOUT] Hibernate: select event0_.ID as ID, event0_.DESCRIPTION as DESCRIPT4_,event0_.EVENTNAME as EVENTNAME from EVENT event0_ where (event0_.EVENTNAME like "%vikas )
19:24:52,750 DEBUG [BatcherImpl] preparing statement
19:24:52,750 DEBUG [JDBCExceptionReporter] SQL Exception
java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"%vikas )' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:314)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at com.xxx.event.EventSessionBean.searchEvents(EventSessionBean.java:496)

Name and version of the database you are using:
MySql 4.1.4-gamma-nt-log
The generated SQL (show_sql=true):
19:24:52,750 DEBUG [QueryTranslator] HQL: select event from com.xxxx.Event event where event.name like "%vikas's%" and event.accessLevel = "1"


Debug level Hibernate log excerpt:


I've found on google that a bug has been created for it , but I couldn't find if its fixed.


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

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.