-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to query with the Expressions 'like'
PostPosted: Thu Feb 16, 2006 1:18 pm 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1.1

Hi guys,

Code:
        <query name="findPostingDetailsByCategoryAndCity"><![CDATA[
            from PostingDetails as pid left join pid.lessorAddress as addr right join pid.categorizedItems as ci where addr.city like ?% and ci.id.categoryId = ?
        ]]></query> 


and got error message below:

Errors in named queries: findPostingDetailsByCategoryAndCity

after putting in the %. Pls help, Thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 1:24 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
remove the % from the query and bind it together with the string to the query


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 9:56 pm 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
I have changed my query like this in the DAO implemenentation:

Code:
   public List findPostingDetails(Long categoryId, String city){
      List list = getHibernateTemplate().findByNamedQuery(
            "findPostingDetailsByCategoryAndCity",
            new Object[] { city + "%", categoryId });

      if (list.size() < 1)
         return null;

      return list;
   }



but return not result. if I remove the '%', it returns some result !
pls help, Thanks !


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