-->
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.  [ 6 posts ] 
Author Message
 Post subject: Criteria Query Question, ignore case for in condition
PostPosted: Wed Mar 23, 2005 7:30 pm 
Newbie

Joined: Wed Mar 02, 2005 7:41 pm
Posts: 7


Hi,

Using Criteria query api, how do I write a where condition, which will give me list of equipments for case-insensitive equipment names, I have available in a Collection.

I understand that for case sensitive where clause, I can use the following ...

I already have a list of equipment names in namesCollection converted to upper case.

Criteria criteria = session.createCriteria(Equipment.class);
criteria.add(Expression.in("equipmentName", namesCollection));
List equipList = criteria.list();

To ignore case, I also want to add something like upper function to equipmentName. How do I do that, using Criteria query API.

Please advise.

Thanks

JP



Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: Hibernate 3

Mapping documents: None

Code between sessionFactory.openSession() and session.close(): None

Full stack trace of any exception that occurs: None

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true): None

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 4:27 am 
Beginner
Beginner

Joined: Thu Apr 28, 2005 6:16 am
Posts: 20
Hi J_p,

I need to do something similar. Did you find out the answer?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 4:29 am 
Beginner
Beginner

Joined: Thu Apr 28, 2005 6:16 am
Posts: 20
FYI: You can do case insensitive LIKE criteria using Expression.ilike.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 5:58 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi
You can do like this

criteria.add(Expression.in("equipmentName", namesCollection).ignoreCase);

or u can use ilike

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 12:53 pm 
Newbie

Joined: Tue Jan 09, 2007 12:45 pm
Posts: 13
ramnath wrote:
Hi
You can do like this

criteria.add(Expression.in("equipmentName", namesCollection).ignoreCase);

or u can use ilike


This Does not work


Top
 Profile  
 
 Post subject: Solution
PostPosted: Tue May 15, 2007 4:51 am 
Newbie

Joined: Tue May 15, 2007 4:10 am
Posts: 2
merlyn wrote:
Hi J_p,

I need to do something similar. Did you find out the answer?


To apply ignorcase you can use this:

Criteria crit=session.createCriteria(Disc.class);
crit.add(Expression.ilike("title","%ill%")); // ilike means ignorecase
crit.add(Expression.eq("language","english").ignoreCase()); //trivial
crit.list();

or you can use this one:

Criteria crit=session.createCriteria(Disc.class);
crit.add(Expression.like("title","bill",MatchMode.ANYWHERE).ignoreCase());
crit.list();


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