-->
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.  [ 12 posts ] 
Author Message
 Post subject: Case sensitive comparsion in HQL
PostPosted: Fri May 13, 2005 6:05 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
Hibernate version: 3.0.3

Hi all,

Is there case sensitive comparsion in HQL ? eg.:

FROM Foo as a WHERE a.property='Any WoRdS'

I can use "binary" keywords in Hibernate 2 - in HQL - that was right for me, when I use that the result was good.

I would like that the comparsion only will be true if the property's String exatly equals to 'Any WoRdS'.
Is it possible?

Thx: Beci


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:07 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
your query do what you want


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:16 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
Sorry I'dont understand it :( I try a lot of different mode but the comparsion never was case sensitive, but only in Hibernate 2 where can I use "binary" keyword before string comparsion :((( In H3 I can't do it :(


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:31 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
FROM Foo as a WHERE a.property='Any WoRdS'

do case sensitive comparison (return exactly 'Any WoRdS' )

If you want case insensitive try

FROM Foo as a WHERE upper(a.property)=upper('Any WoRdS')
(if your dialect support upper function)

Have you tried ? If it doesn't work you have problem with database (what is sql query then)
regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:39 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
I use "mysql 4.0.24-standard (on Debian)" with "mysql-connector-java-3.0.14-production-bin.jar" lib.

I try again and I hope it will be sucessfull:)

Do you say the HQL comparsion is case sensitive on basic?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:40 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
Sorry thx your previous answer :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:01 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
Do you say the HQL comparsion is case sensitive on basic?

yes - see generated sql


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:23 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
I saw the generated code see below:

select keresletel0_.meghatarozas as col_0_0_ from keresletElhelyezkedes keresletel0_ where keresletel0_.meghatarozas=?

?='AnY WoRd'

And the comparsion is not case sensitive (not only in java) :( because there isn't the "binary" keyword for the case sensitivity for mysql.

I don't know what is the solution in HQL for this :(


10^6 Thx :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:33 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
select keresletel0_.meghatarozas as col_0_0_ from keresletElhelyezkedes keresletel0_ where keresletel0_.meghatarozas=?

?='AnY WoRd'


this sql have to return only column/columns with value = exactly 'AnY WoRd'
If you get another your sql server (mysql or what) isn't good and it is case sensitive

If you want case insensitive results use (I misunderstand, maybe)

from table a where upper(a.property) = upper(?)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:40 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
Please see this: http://mysqld.active-venture.com/Case_S ... ators.html

And especially this address: http://dev.mysql.com/doc/mysql/en/case-sensitivity.html

So I think the problem is with mysql version :( or table column properties.

Bye


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:45 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I don't know mysql , but it is correct sql for your need - your problem is mysql


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 7:47 pm 
Newbie

Joined: Wed May 04, 2005 5:38 pm
Posts: 15
Hello,

I found the solution finally (I hope :) )

I define the varchar column in the table with binary keyword :) and everything is allright

Thank you very much your help


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