persistence@glassfish.java.net

Re: Question about Query.setFirstResult/setMaxResult

From: Linda DeMichiel <Linda.Demichiel_at_Sun.COM>
Date: Fri, 03 Mar 2006 09:26:46 -0800

Hi Michael,

Michael Bouschen wrote:

> Hi Linda, hi Mike,
>
> there is a forum question about the semantics of Query.setFirstResult
> and Query.setMaxResult:
> http://forums.java.net/jive/thread.jspa?threadID=13567&tstart=0
>
> Does the maxResult argument of Query.setMaxResult specify the maximum
> index to be retrieved or the result set length? So does a query
> specified with setFirstResult(2) and q.setMaxResults(3) return
> (1) the values from index 2 to 3 (including or excluding) or
> (2) 3 results starting with index 2, so the values at index 2, 3, 4.
>

The maximum number of results-- i.e, (2).


> I read the spec that (2) is the right answer, so maxResult specifies a
> result length. The current implementation does (1) excluding, so the
> above returns the values at index 2.
>
> Thanks!
>
> Regards Michael