You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Patel Amit <ap...@us.axway.com> on 2008/06/24 20:26:30 UTC

JPA Pagination

Hi,

 

I have a question about JPA Pagination.  I'm using the setFirstResult
and setMaxResults on the JPA Query object.  These features work great
(using OpenJPA 1.1.0).  My question is, is there a way to get the total
number of results returned even with the page number settings set?  For
example, if I set the MaxResults to 10, and the total results of the
query is 25 (without setting the MaxResults) is there a way to get the
25 value?  Right now, I'm just issuing a second query without the
maxResults set and getting the collection size, but I'm wondering if
there is a more efficient way of doing it.

 

Thanks for the help.

 

Amit Patel 

 


Re: JPA Pagination

Posted by Roger Keays <ro...@ninthavenue.com.au>.
Patel Amit wrote:
> Hi,
> 
>  
> 
> I have a question about JPA Pagination.  I'm using the setFirstResult
> and setMaxResults on the JPA Query object.  These features work great
> (using OpenJPA 1.1.0).  My question is, is there a way to get the total
> number of results returned even with the page number settings set?  For
> example, if I set the MaxResults to 10, and the total results of the
> query is 25 (without setting the MaxResults) is there a way to get the
> 25 value?  Right now, I'm just issuing a second query without the
> maxResults set and getting the collection size, but I'm wondering if
> there is a more efficient way of doing it.

We do the same thing, although OpenJPA has a proprietary feature for 
large result sets (LRS). I've tried it out but prefer the manual method.
> 
>  
> 
> Thanks for the help.
> 
>  
> 
> Amit Patel 
> 
>  
> 
> 


Re: JPA Pagination

Posted by Roger Keays <ro...@ninthavenue.com.au>.
Patel Amit wrote:
> Hi,
> 
>  
> 
> I have a question about JPA Pagination.  I'm using the setFirstResult
> and setMaxResults on the JPA Query object.  These features work great
> (using OpenJPA 1.1.0).  My question is, is there a way to get the total
> number of results returned even with the page number settings set?  For
> example, if I set the MaxResults to 10, and the total results of the
> query is 25 (without setting the MaxResults) is there a way to get the
> 25 value?  Right now, I'm just issuing a second query without the
> maxResults set and getting the collection size, but I'm wondering if
> there is a more efficient way of doing it.

@see also 
http://www.ilikespam.com/blog/paging-large-data-sets-with-a-lazylist

> 
>  
> 
> Thanks for the help.
> 
>  
> 
> Amit Patel 
> 
>  
> 
>