Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-722

Please consider implementing external iterator for results

Add voteWatch issue


    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Core
    • None


      Please consider implementing an external iterator for mapped results.

      iBatis currently offers an internal/push iterator via IoC with SqlSession.select(...) and ResultHandler. This results in complicated client implementations when used with a pull API such as StAX. This requires the introduction of an additional thread, buffering and associated concurrency as well a complication error detection and handling.

      The API and associated semantic of an external iterator implementation might look something like this.

      String selectId = ...
      Object parameters = ...
      SqlSessionFactory sqlSessionFactory = ...
      SqlSession sqlSession = sqlSessionFactory.openSession();
      ResultIterator resultsIterator = sqlSession.selectMultiple(selectID, parameters);
      // hand resultIterator off to some pull API (i.e. wrap in StAX XMLEventReader implementation and stream your GiBi of data into the ether, yay!)

      // the resultIterator API might look like this...
      public class ResultIterator implements Iterator<Object> {
      // Implement Iterator.next()
      public Object next()

      { // return next mapped object // if result set exhausted close it, do cleanup, make sure hasNext() results 'false' ... }

      // Implement Iterator.hasNext()
      public boolean hasNext()

      { // result set exhausted, stop() called? ... }

      // Implement Iterator.remove()
      public void remove()

      { // not going to work in this context... throw new UnsupportedOperationException(); }

      public stop()

      { // analog to ResultHandler/ResultContext.stop() // do cleanup, i.e. close result set make sure subsequent hasNext() returns 'false' }





            Unassigned Unassigned
            tck Tom Kunicki




                Issue deployment