-->
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.  [ 5 posts ] 
Author Message
 Post subject: Order problem with upper- and lowercase letters
PostPosted: Thu Nov 10, 2005 4:15 pm 
Newbie

Joined: Wed Nov 02, 2005 4:29 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.something

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 8.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Has anybody have problems like this when trying to order a query answer? I try to order on field name and it works fine for names starting with uppercase letters, but names starting with a lower case letter always gets order last, no matter what letter it starts with. For example I get the resulting list in this order:

Angela A
Boris B
Charlotte C
Michael M
Warner W
angela b
boris c
charlotte d

Of course I want it in this order:
Angela A
angela b
Boris B
boris c
Charlotte C
charlotte d
Michael M
Warner W


Does anybody know what is wrong?

Regards

Pich


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 4:38 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
in ASCII comparisons, which is what most String comparisons do, all capital letters are greater than lower case letters :)

http://www.lookuptables.com/

_________________
Chris

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


Top
 Profile  
 
 Post subject: upper() or lower()
PostPosted: Thu Nov 10, 2005 4:43 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Are you doing your ordering in HQL (order by clause)? Wrap your ordering column in upper() or lower():

Code:
<query name="CaseInsensitiveSearch">
  from Table order by upper(SortColumn)
</query>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 4:44 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
kochcp wrote:
in ASCII comparisons, which is what most String comparisons do, all capital letters are greater than lower case letters :)

http://www.lookuptables.com/



errr, lower than

_________________
Chris

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


Top
 Profile  
 
 Post subject: Re: upper() or lower()
PostPosted: Fri Nov 11, 2005 3:50 am 
Newbie

Joined: Wed Nov 02, 2005 4:29 am
Posts: 7
tenwit wrote:
Are you doing your ordering in HQL (order by clause)? Wrap your ordering column in upper() or lower():

Code:
<query name="CaseInsensitiveSearch">
  from Table order by upper(SortColumn)
</query>



Thanks a lot, worked like a charm!


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