Hello David,
I been there before and what i did was kinda like a double query, one for the result and the other one for the count of the unpaged results. Hibernate do have a
ScrollableResult that could help you a little with this.
This it's a reality that many of us encounter time to time when working with db, because of the paging and all that stuff, but there it's a
pattern to solve this. Here explains about the
Pagination pattern with diagrams and stuff.