How do you implement a Page-By-Page iterator??

Discussions

EJB design: How do you implement a Page-By-Page iterator??

  1. How do you implement a Page-By-Page iterator?? (1 messages)

    There have been posts on this site asking what the best method is to retrieve a large amount of data (1000+ rows) from a database. The suggested approach is to use a page-by-page iterator, as seen on http://java.sun.com/blueprints/patterns/j2ee_patterns/page_by_page_iterator/index.html

    My question is, how do you implement a page-by-page iterator with CMP beans?

    Right now, I am using a simple finder to retrieve a Collection of 1000+ entity beans. How would I implement a page-by-page iterator and bypass the finder method (because this is expensive since there are many remote calls to populate each bean's data). I guess I could roll my own JDBC code, but this introduces longer coding times, handling JDBC failure conditions, getting JDBC connections, etc... Is it really worth it?

    Thanks for any help!!
    Dan
  2. Using entity bean finder method for retrieving thosands of records is a recipe for disaster. I have implemented a page by page iterator as follows

    - A singleton caches stores the result set which is obtained by straight JDBC calls
    - The cache is accessed through SLSB
    - The client invokes a method on the SLSB and passes an instance of a PageIterator class. This class encapsuales the client state by storing current location, page size etc.

    There are other variations of this general approach.

    Pranab