Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
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()
// Implement Iterator.hasNext()
public boolean hasNext()
// Implement Iterator.remove()
public void remove()
public stop()
{ // analog to ResultHandler/ResultContext.stop() // do cleanup, i.e. close result set make sure subsequent hasNext() returns 'false' }}