-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate query using named parameter and %
PostPosted: Sun Feb 19, 2006 8:52 am 
Newbie

Joined: Mon May 02, 2005 4:29 am
Posts: 5
I am having some difficulties creating a hibernate query using both named parameters and the %.

For instance when i search for a certain product using a named query and named parameters it looks like this :

<query name="searchProducts">
<![CDATA[from Product where amount != 0 and namelike %:searchText% or title like %:searchText%]]>
</query>

I can't get it to work.

Can anybody help me out?

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 19, 2006 5:25 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You'll have to put the %s in the bound variable, not in the HQL.
Alternatively, you could use Criteria: the like/ilike Restrictions allow MatchMode.ANYWHERE.


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