aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes I can set the max results on a query, but can I find what the total would have been without (Paging) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "I can set the max results on a query, but can I find what the total would have been without (Paging)" Watch "I can set the max results on a query, but can I find what the total would have been without (Paging)" New topic
Author

I can set the max results on a query, but can I find what the total would have been without (Paging)

Theodore David Williams
Ranch Hand

Joined: Dec 21, 2009
Posts: 102
I am executing a query and on that query I am setting the max results I want back from the data base. How ever I still need to know what the total number of results would have been if I did not limit the query.



I think I can setup a criteria, but then I would have to but in the same info as in my query object, do I really need to create a criteria object and query the DB again to the total?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

As a general database question, the main point of telling the database to just give you the top 50 results is so that it doesn't have to go through all 12,397 results. And therefore it would be completely unreasonable to expect it to produce the number 12,397 from that top-50 query.

Does that answer your question?

Also, the usual way to find out the size of a query is to use a "Select count(*) from ..." type of query. That also frees the database from having to return all 12,397 rows across the network just so that something can count the rows. But sorry, I don't know how you do that with an entity manager.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I can set the max results on a query, but can I find what the total would have been without (Paging)