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: Criteria query with "formula" field used as ordering
PostPosted: Mon Mar 29, 2010 1:14 am 
Newbie

Joined: Mon Nov 12, 2007 6:36 pm
Posts: 6
Hi,

What I am trying to do is retrieve some data using the Criteria method. However I want to order the results by a calculation on some of the fields in the row, a calculation that is never stored in the data objects.

Eg,

I do something like this right now

Criteria c = super.getSession().createCriteria(Listing.class);

if (search.getName() != null)
c.add(Restrictions.ilike("name", "%" + search.getName() + "%"));

c.setMaxResults(search.getMaxResults());
return c.list();


But I want to also add in there something that lets by order by the sin of the angle field.

eg,

c.addOrder("sin(angle)");

where sin would use the built in function of mysql.

(I'm not actually using sin but it demonstrates my purposes well).

Any help appreciated!


Top
 Profile  
 
 Post subject: Re: Criteria query with "formula" field used as ordering
PostPosted: Sun Apr 11, 2010 12:32 am 
Newbie

Joined: Mon Nov 12, 2007 6:36 pm
Posts: 6
Anyone help ?


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.