Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] total rowCount with JPA

Hi,
AFAIK there is no such a way available with JPA 1. You should do a
either "SELECT COUNT(o) FROM Object o", or
Query.getResultList().size().

Mohsen.

On Fri, May 9, 2008 at 11:28 AM, Leon Derks <leon.derks@xxxxxxxxxx> wrote:
> Hello
>
> I know how to implement pagination, using JPA.
>
> But I also would like to know how I can get the total number of results.
>
> For example Hibernate uses a projection for this(see below), but how can I
> do this using JPA?
>
> criteria.setFirstResult(0);
> criteria.setMaxResults(java.lang.Integer.MAX_VALUE);
> criteria.setProjection(Projections.rowCount());
> int rowCount = (Integer) criteria.list().get(0);
>
> Leon
>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top