Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Get result count from criteria query

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


Back to the top