I'm not sure I understand your question and your different approaches right. I'm using separate methods for getting the count of a query and the result of a query. Then for pagination the client code may store the count or not, for example to have an upper limit for the max index but that's quite unimportant for the server part. The client simply request one page after another, e.g. using a method like this: List<Article> fetchBy(String name, ..., Integer start, Integer max); where start and max would be optional. For complex searches and in order to be able to cache results for similiar queries I do use Objects which contain all the search parameters and the count but this is just for checking the upper limit. They never contain the result.
Hope that helps a litte bit...
|