Get result count from criteria query [message #724377] |
Mon, 12 September 2011 04:37  |
Eclipse User |
|
|
|
Hello,
I build an criteria query, to get some entities from the database.
For pagination reasons, I set firstResult and maxResults to get only a subset of the total result.
Is there a way to get the whole entity count of this query, without manually building a second count query?
This is because I want to build a method in my service base class, that returns the paginated result, by giving it only the query object that returns the results.
I imagine something like this:
public<T> PaginatedResult<T> executeQuery(CriteriaQuery<T> query, Paginator paginator) {
....
}
The Paginator object includes firstResult and maxResults and the PaginatedResult contains the List<T> and a totalResults fields.
So the concrete service implementation has to build the query, to get its data, and the above method executes this and gets the data AND the total results, this query would return without pagination.
My problem is, that I have to build a second "count query", but in this method I've no informations about the where-clauses, etc attached to the query.
thanks
Dirk
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25926 seconds