All in all I think your current approach is actually fine, considering you are paging over >50000 rows of data. The user will only ever be able to take in a page at a time anyway, maybe 50 results on a single page.
However if I understand you correctly, its the fact that you have to issue a new query for each page of results that is bothering you?
If so I have an alternative suggestion for you.
Pre-fetch more than one page at time, so if the user can see 50 results in a page, pre-fetch 200, then as the user pages forward you can always read ahead, so there is no noticeable lag from a user perspective.
You can determine how many rows to fetch based on the memory consumption of you Order objects.
Cheers,
Conor.
Having re-read your post, I am not sure if this is what you are looking for, if you are really creating a report, I am not sure if hibernate in appropriate in this instance, esp if you don't really need to work with the object model afterwards.
|