Depends on where you want to control it and how reliable you feel
about it being in the first 10-20 records, or if what you're really
after is paging behavior in which case things change a bit.
Assumptions (Potential hazard) : You're running server side java in a
browser implementation wherein, your interface (jsp) elements are
displayed in a browser and you want the operational (behavioral) code
on the server side. Basic web implementation type of thing. If
you're doing a desktop swing app or similar your mileage will vary.
One thing I've done in similar situations was to actually bring back
all of the primary keys I might need, for example, search returns a
result of 1000 records, but I'm only getting the primary keys and
maybe a descriptor. I put ALL of the records into objects which get
stored in a wrapper class that has the behavior for paging the 1000
records in pages of say 25. The wrapper class has to be able to keep
up with the page size and the current page which yields an index range
of objects in the collection that will allow you to perform paging
behavior without having to A) go back to the database over and over
again. (You actually will go back to the database, but not to get
this list or any part of it) and B) to more efficiently manage how
much information your pulling from the database at any given time.
In my experience, RDBMS systems and networks do not like moving large
blocks of information, they'll do it, but they're happier moving lots
of little bits of information. This approach allows you to do that.
It's semantically a different way of thinking about doing data
exchange.
If you're interested I have a wealth of information available and
would be happy to share. Feel free to email me.