-->
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: Compare two varchar with ignoreCase
PostPosted: Mon Aug 30, 2004 5:44 am 
Newbie

Joined: Wed Jul 21, 2004 3:58 am
Posts: 17
Hi guys !

I'm my application, I'd like two compare two strings before insert an object in the database to test the unicity.

Here is a part of my code !
uery query = session
.createQuery("select count(*) from ClientDTO client where client.nom=:nom");
query.setParameter("nom", client.getNom());
int count = ((Integer) query.uniqueResult()).intValue();
if (count != 0) {.....}

Is there a way to compare two varchar with ignoring the case ? Because if the parameter is "walmart" and if there is an entry in the database like "WALMART", the query won't have result.

Someone have a solution ?

Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 5:49 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Try with:
[code]Query query = session.createQuery("select count(*) from ClientDTO client where upper(client.nom)=upper(:nom)");


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 6:01 am 
Newbie

Joined: Wed Jul 21, 2004 3:58 am
Posts: 17
Ok it's working !

Thx a lot !


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.