-->
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: Any way to force case sensitive searches?
PostPosted: Fri Nov 11, 2005 2:57 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
I have an HQL query that works pretty well, it gets what I have requested it to find ... However,

The code which Hibernate is replacing performed case sensitive searches of the database; that is, If I have "Fred" stored in the databse and guery for "fred" it would not find that. It would only find "Fred" if I queried for "Fred".

Is there any way to force that behavior with Hibernate?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 3:02 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
just make everything uppercase for the query.

from Table t where upper(t.name)=:name

and in your code make everything uppercase just for query use.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 6:29 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
But how does that make my queries of data in the database case sensitive? It seems to me that this just ensures case insenitivity, which is essentially what I am experiencing now.

Let me clarify: If I have stored in the database the string value, "Fred", and the user enters "fred" in the search screen, I want the search to FAIL to find anything (assuming I do not have value "fred" in the database). I want the search to succeed only if the user enters "Fred" (exact, by case).

I want to know if I can force Hibernate to behave in its queries (this specific query) in a case sensitive manner.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 9:05 pm 
Beginner
Beginner

Joined: Tue Oct 18, 2005 3:57 pm
Posts: 48
Location: Los Angeles, CA
If I remember correctly, SQL string matching is case-insensitive, so you need to look at vendor-specific options (collation?).


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.