-->
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: varchar2 needs sorted as integer
PostPosted: Tue Mar 31, 2009 1:33 pm 
Newbie

Joined: Fri Jan 09, 2009 12:52 pm
Posts: 6
I am trying to create a query HQL or Criteria that will return the result set sorted numerically, however, the numbers I need to sort, are in an varchar2 field. I looked at using a @Transient field, but could not get that to work. I also tried to use @Formula, but that would not work. Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 31, 2009 5:13 pm 
Beginner
Beginner

Joined: Fri May 14, 2004 9:50 am
Posts: 28
Hello,

In your mappin or annotation you can add a sort element and use a comparator class :

Look at the 2.4.6.1 :
http://www.hibernate.org/hib_docs/annot ... ntity.html

http://www.hibernate.org/hib_docs/v3/re ... ons-sorted

_________________
Eric

http://www.viaxoft.com
http://blog.viaxoft.net


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 01, 2009 6:46 am 
Newbie

Joined: Fri Jan 09, 2009 12:52 pm
Posts: 6
yeah, I guess I really wasn't wanting to create a new class just to do a sort. There are several ways to do it if i start creating new classes. Seems like there should be an easier way to do such a simple task?


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.