Package org.apache.ibatis.cursor
Interface Cursor<T>
- All Superinterfaces:
AutoCloseable
,Closeable
,Iterable<T>
- All Known Implementing Classes:
DefaultCursor
public interface Cursor<T> extends Closeable, Iterable<T>
Cursor contract to handle fetching items lazily using an Iterator.
Cursors are a perfect fit to handle millions of items queries that would not normally fit in memory.
If you use collections in resultMaps then cursor SQL queries must be ordered (resultOrdered="true")
using the id columns of the resultMap.
- Author:
- Guillaume Darmont / [email protected]
-
Method Summary
Modifier and Type Method Description int
getCurrentIndex()
Get the current item index.boolean
isConsumed()
boolean
isOpen()
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
isOpen
boolean isOpen()- Returns:
- true if the cursor has started to fetch items from database.
-
isConsumed
boolean isConsumed()- Returns:
- true if the cursor is fully consumed and has returned all elements matching the query.
-
getCurrentIndex
int getCurrentIndex()Get the current item index. The first item has the index 0.- Returns:
- -1 if the first cursor item has not been retrieved. The index of the current item retrieved.
-