-->
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: Search Records By Astrik(*) and Question (?) in Hibernate.
PostPosted: Tue Dec 09, 2008 12:56 am 
Newbie

Joined: Wed Dec 03, 2008 8:05 am
Posts: 11
Hi All ,

I am using Hibernate in my Project.

Iam Developing a Search Page .

Recently I got a requirment.

In the Search Page if I enter * or ? records should be display .

For Ex. say in any text box if enter "RE*" or "RE?" related records should be populated in the search page.


My Query is can we achive this by Hibernate . Is there any special method present in the class or any special class exisit?


Can any one help me plzzzzzzzzzzzz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 3:52 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It is not really Hibernate that does the searching but your underlying database. Most databases supports the LIKE operator which you may use as: someColumn LIKE 'foo%', where % matches any number of characters. A lot of examples can be found here: http://www.hibernate.org/hib_docs/v3/re ... sions.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 5:13 pm 
Newbie

Joined: Tue Dec 09, 2008 4:56 pm
Posts: 6
Just simply do a replaceAll(regex, replacement) to manually replace the '*' with the '%'


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.