-->
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: How to do a simple "search"-function with wildcard
PostPosted: Sat Jun 04, 2005 1:22 pm 
Newbie

Joined: Sat Jun 04, 2005 1:15 pm
Posts: 5
Hi everybody,

till now I have gained a lot of experience using hibernate. Nevertheless I'm struggling with a very simple problem: how can I do a simple search-function with hibernate?

I have a couple of "text-components" and I want to create a jsp-page on which the can enter something like "search: 123* " but how can I do this? Till now I just know the

SELECT comp FROM Textcomponent as comp WHERE text='123*' but this query will not return any results because it will interpret the * as a character.

So how can I realize such a search-function? What is the correct query


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 04, 2005 9:19 pm 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
try like+%

Quote:
from eg.DomesticCat cat where upper(cat.name) like 'FRI%'

use % , not *.

read http://www.hibernate.org/hib_docs/reference/en/html_single/#queryhql-expressions


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 3:52 am 
Newbie

Joined: Sat Jun 04, 2005 1:15 pm
Posts: 5
thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 9:45 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi

add this to to ur like
replace("%", "*")

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
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.