Package org.apache.cayenne.access.jdbc
Class ConnectionAwareResultIterator<T>
java.lang.Object
org.apache.cayenne.access.jdbc.ConnectionAwareResultIterator<T>
- All Implemented Interfaces:
AutoCloseable
,Iterable<T>
,ResultIterator<T>
A
ResultIterator
wrapper that handles closing a connection. Also
internally counts processed rows, mostly for the benefit of subclasses.
Subclasses are used in iterators that are returned to the end users and are
not implicitly managed by Cayenne.- Since:
- 4.0
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConnectionAwareResultIterator
(ResultIterator<T> delegate, Connection connection) -
Method Summary
Modifier and TypeMethodDescriptionallRows()
Returns all yet unread rows from ResultSet without closing it.void
close()
Closes ResultIterator and associated ResultSet.protected void
doClose()
boolean
Returns true if there is at least one more record that can be read from the iterator.iterator()
nextRow()
Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.void
skipRow()
Goes past current row.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
rowCounter
protected int rowCounter
-
-
Constructor Details
-
ConnectionAwareResultIterator
-
-
Method Details
-
close
public void close()Description copied from interface:ResultIterator
Closes ResultIterator and associated ResultSet. This method must be called explicitly when the user is finished processing the records. Otherwise unused database resources will not be released properly.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceResultIterator<T>
-
doClose
protected void doClose() -
allRows
Description copied from interface:ResultIterator
Returns all yet unread rows from ResultSet without closing it.- Specified by:
allRows
in interfaceResultIterator<T>
-
hasNextRow
public boolean hasNextRow()Description copied from interface:ResultIterator
Returns true if there is at least one more record that can be read from the iterator.- Specified by:
hasNextRow
in interfaceResultIterator<T>
-
nextRow
Description copied from interface:ResultIterator
Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.- Specified by:
nextRow
in interfaceResultIterator<T>
-
iterator
-
skipRow
public void skipRow()Description copied from interface:ResultIterator
Goes past current row. If the row is not needed, this may save some time on data conversion.- Specified by:
skipRow
in interfaceResultIterator<T>
-