R
- the type of storage records@Internal
public abstract class DbIterator<R>
extends java.lang.Object
implements java.util.Iterator<R>, java.io.Closeable
ResultSet
of storage records.
This class internally uses ResultSet
.
See how to finish the usage of the iterator properly.
Uses Serializer
to deserialize records.
NOTE: remove
operation is not supported.
Modifier and Type | Class and Description |
---|---|
static class |
DbIterator.DoubleColumnRecord<A,B>
A holder of a pair of column values for the simultaneous iteration over a
ResultSet . |
Modifier and Type | Method and Description |
---|---|
void |
close()
|
boolean |
hasNext() |
R |
next() |
static <A,B> DbIterator<DbIterator.DoubleColumnRecord<A,B>> |
over(java.sql.ResultSet resultSet,
ColumnReader<A> columnReaderA,
ColumnReader<B> columnReaderB)
Creates a
DbIterator for the simultaneous iteration over the entity records and
their IDs in the ResultSet . |
static <R> DbIterator<R> |
over(java.sql.ResultSet resultSet,
ColumnReader<R> columnReader)
Creates a
DbIterator over the given ResultSet . |
protected abstract R |
readResult() |
void |
remove()
Deprecated.
as unsupported
|
java.sql.ResultSet |
resultSet() |
public static <R> DbIterator<R> over(java.sql.ResultSet resultSet, ColumnReader<R> columnReader)
DbIterator
over the given ResultSet
.R
- the type of storage recordsresultSet
- the results of a DB query to iterate overcolumnReader
- the column reader which extracts the required column values from the result setDbIterator
public static <A,B> DbIterator<DbIterator.DoubleColumnRecord<A,B>> over(java.sql.ResultSet resultSet, ColumnReader<A> columnReaderA, ColumnReader<B> columnReaderB)
DbIterator
for the simultaneous iteration over the entity records and
their IDs in the ResultSet
.A
- the type of values in the first columnB
- the type of values in the second columnresultSet
- the results of a DB query to iterate overcolumnReaderA
- the reader of the first columncolumnReaderB
- the reader of the second columnDbIterator
public boolean hasNext()
Calls close()
, if ResultSet.next()
returns false
.
hasNext
in interface java.util.Iterator<R>
protected abstract R readResult() throws java.sql.SQLException
java.sql.SQLException
public java.sql.ResultSet resultSet()
@Deprecated public final void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator<R>
java.lang.UnsupportedOperationException
- alwayspublic void close() throws DatabaseException
resultSet
and the related Statement
and Connection
.
This method should be called either manually or called by hasNext()
.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
DatabaseException
- if SQLException
occurred