-->
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: Criteria Query not working for single quotes
PostPosted: Wed Aug 10, 2011 10:19 am 
Newbie

Joined: Wed Aug 10, 2011 10:05 am
Posts: 1
Hello All,


I am using Hibernate 3.0,and i have following query..

My Criteria query is
.
.
Code:
if (city != null && city.trim().length() > 0){
   criteria.add(Restrictions.ilike("city", city.trim(), MatchMode.ANYWHERE));
}

criteria.list();


This is throwing error for when city is 'ahmedabad' i am passing city with single quotes at start and at the end as well.

Criteria Query forms like :-
CriteriaImpl(com.map.cms.bus.data.POI:this[][city ilike %'ahmedabad'%])

It shows following error


Code:
ERROR org.hibernate.util.JDBCExceptionReporter  - ERROR: syntax error at or near "ahmedabad"
  Position: 74
ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mapcms_ui].[mapcms]  - Servlet.service() for servlet mapcms threw exception
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
   at org.hibernate.loader.Loader.doList(Loader.java:2231)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
   at org.hibernate.loader.Loader.list(Loader.java:2120)
   at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
   at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
   at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
   at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
   at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835



Thanks in advance...


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.