persistence@glassfish.java.net

RE: Fix for setFirstResult/setMaxResults issue

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Wed, 15 Mar 2006 11:59:42 -0500

Hey Michael,
        My only concern with this change is that this TopLink API (setMaxRows, setFirstResult) are defined to be straight pass-through to JDBC. No arithmetic should be performed on these values once they are set on the query. Perhaps the arithmetic could be limited to the APIs on EJBQueryImpl. This would be more complicated here as there is no guarantee on the order in which the APIs would be called. Another alternative would be to add new APIs to ReadQuery that would be defined to 'float' MaxRows.
--Gordon

-----Original Message-----
From: Michael Bouschen [mailto:Michael.Bouschen_at_Sun.COM]
Sent: Wednesday, March 15, 2006 11:33 AM
To: Tom Ware; Gordon Yorke
Cc: persistence_at_glassfish.dev.java.net
Subject: Fix for setFirstResult/setMaxResults issue


Hi Tom, Hi Gordon,

I looked at the glassfish issue 344 about setFirstResult and setMaxResults:
   https://glassfish.dev.java.net/issues/show_bug.cgi?id=344

I followed the proposal Peter added to the glassfish issue and changed
the code in class DatabaseCall method prepareStatement from
     if (getMaxRows() > 0) {
         statement.setMaxRows(getMaxRows());
     }
to
     if (getMaxRows() > 0) {
         statement.setMaxRows(getFirstResult() + getMaxRows());
     }

This fixes the issue.

I would like to check in the fix, if there are no objections.

Regards Michael