-->
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.  [ 2 posts ] 
Author Message
 Post subject: order by custom function instead of table field
PostPosted: Thu Sep 16, 2004 2:42 pm 
Newbie

Joined: Mon Aug 30, 2004 5:15 pm
Posts: 13
Hibernate version: 2.1.6

I have a class Task that corresponds to a database table Task. I have extended the Task class to include a custom function:

Code:
   public int numDaysRemaining() {
       ....
    }


Is there a way to use this function is a query? I want to order by results by this function, ie.

Code:
from Task task order by task.numDaysRemaining()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 16, 2004 3:49 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Not as far as I know...

According to me, your only option is to sort the list returned by the query yourself.

You could build a Comparator using your function and Collections.sort() your list - or use the Jakarta Collections lib.


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