File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes HQL paginateing and sorting problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HQL paginateing and sorting problem" Watch "HQL paginateing and sorting problem" New topic

HQL paginateing and sorting problem

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi all
I have simple html grid (html table) displaying page 5 of 10 pages (each page contain 5 rows)
currently when i sort the grid - the page data is lost (because i am sorting all results not just page 4 results)
I would like to sort just the results of page 5 ,
Is it possible to sort the current page using HQL or I have to sort the result list with comparator?
I got the page rows by running:

Thank you
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 659

you can implement a ResultTransformer and sort it.
personally, I'd prefer having some sort of UI plug-in which can sort only the page data because the data can be sorted in any order from the UI.
If it is a simple sort and if it is not going to change, you can always add a order by clause at the end of your query.

If you are not laughing at yourself, then you just didn't get the joke.
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Thank you Arun
Client side sorting won’t be easy (since its a web application..)
Thank you for the reference, I will investigate the ResultTransformer class.
I agree. Here's the link:
subject: HQL paginateing and sorting problem