Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ORDERBY with findAll() in Play

is there any way i can use ORDERBY with findAll() in Play Framework?

like image 922
svenkubiak Avatar asked Mar 04 '11 18:03

svenkubiak


2 Answers

Model.findAll() is a shortcut which fetches the results right away, it's equivalent to Model.all().fetch().

I think the best way to specify order is by using a JPQL query like this:

Model.find("order by fieldName desc").fetch();

like image 73
mike Avatar answered Sep 30 '22 10:09

mike


This line seemed to work for me (play 2.1)

find.where().orderBy("fieldname desc").findList()
like image 45
Rob Hoff Avatar answered Sep 30 '22 11:09

Rob Hoff