I would like to implement the functionality for large queries where I only get back a "page" or sublist of the results using EJB3. This is mostly easy using the setMaxResults and setFirstResult stuff on Query. However, I don't see anyway to know things like how many total objects there are. I would like to provide info to my users like "showing 1 through 10 of 100" results. I don't want to run the query twice (once with max results and first result and once without to get the total) because that defeats the purpose. I assume this would not only hit the database twice but would end up instatiating all the objects in the whole result set. Has anyone figured a way around this?