persistence@glassfish.java.net

Question about Query.setFirstResult/setMaxResult

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Fri, 03 Mar 2006 18:12:41 +0100

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.

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