-->
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: Expression Like problem
PostPosted: Thu Oct 18, 2007 8:41 am 
Newbie

Joined: Thu Oct 18, 2007 8:30 am
Posts: 3
Hi,

In my database I have a table with a "name" column and one row which contains the value "test"

If I use this criterion :

criteria.add(Expression.like("name", "%test%"))

the query works very well and returns the row.

but if I do this :
criteria.add(Expression.like("name", "%te%"))

nothing is returned!

I thought that by doing this "%te%" the row containing "test" would be return.

What query should I do if I want thto retrieve the row "test" by entering "te" or "t" or "tes"?

thanks


Top
 Profile  
 
 Post subject: Expression Like problem
PostPosted: Sat Oct 20, 2007 3:57 am 
Newbie

Joined: Mon Feb 20, 2006 1:40 am
Posts: 7
Location: Hyderabad
Try using MatchMode.ANYWHERE in the InExpression constructor or Restrictions.in() method. Also, if data in your database is case sensitive, use Restrictions.ilike().

Do not forget to post a reply if this answers your question.

==============================

Shreenath Sreenivas
Senior Software Engineer (TL)
Ocimum Biosolutions


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.