R
- The cursor's record typepublic interface Cursor<R extends Record>
extends java.lang.Iterable<R>
ResultSet
. Unlike Result
, data can only be accessed
sequentially, using an Iterator
, or the cursor's hasNext()
and fetch()
methods.
Client code must close this Cursor
in order to close the underlying
PreparedStatement
and ResultSet
Note: Unlike usual implementations of Iterable
, a Cursor
can only provide one Iterator
!
Modifier and Type | Method and Description |
---|---|
void |
close()
Explicitly close the underlying
PreparedStatement and
ResultSet . |
Result<R> |
fetch()
Fetch all remaining records as a result.
|
Result<R> |
fetch(int number)
Fetch the next couple of records from the cursor.
|
<E> java.util.List<E> |
fetch(RecordMapper<? super R,E> mapper)
Fetch results into a custom mapper callback.
|
<E> java.util.List<E> |
fetchInto(java.lang.Class<? extends E> type)
Map resulting records onto a custom type.
|
<H extends RecordHandler<? super R>> |
fetchInto(H handler)
Fetch results into a custom handler callback.
|
<Z extends Record> |
fetchInto(Table<Z> table)
Map resulting records onto a custom record.
|
R |
fetchOne()
Fetch the next record from the cursor.
|
<E> E |
fetchOne(RecordMapper<? super R,E> mapper)
Fetch the next record into a custom mapper callback.
|
<E> E |
fetchOneInto(java.lang.Class<? extends E> type)
Map the next resulting record onto a custom type.
|
<H extends RecordHandler<? super R>> |
fetchOneInto(H handler)
Fetch the next record into a custom handler callback.
|
<Z extends Record> |
fetchOneInto(Table<Z> table)
Map the next resulting record onto a custom record.
|
<T> Field<T> |
field(Field<T> field)
Get a specific field from this Cursor.
|
Field<?> |
field(int index)
Get a specific field from this Cursor.
|
Field<?> |
field(java.lang.String name)
Get a specific field from this Cursor.
|
Field<?>[] |
fields()
Get all fields from this Cursor.
|
Row |
fieldsRow()
Get this cursor's fields as a
Row . |
boolean |
hasNext()
Check whether this cursor has a next record.
|
boolean |
isClosed()
Check whether this
Cursor has been explicitly or
"conveniently" closed. |
RecordType<R> |
recordType()
Get this cursor's row type.
|
java.sql.ResultSet |
resultSet()
Get the
Cursor 's underlying ResultSet . |
RecordType<R> recordType()
<T> Field<T> field(Field<T> field)
Row.field(Field)
Field<?> field(java.lang.String name)
Row.field(String)
Field<?> field(int index)
Row.field(int)
Field<?>[] fields()
Row.fields()
boolean hasNext() throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
DataAccessException
- if something went wrong executing the queryResult<R> fetch() throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
The result and its contained records are attached to the original
Configuration
by default. Use Settings.isAttachRecords()
to override this behaviour.
DataAccessException
- if something went wrong executing the queryResult<R> fetch(int number) throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
The result and its contained records are attached to the original
Configuration
by default. Use Settings.isAttachRecords()
to override this behaviour.
number
- The number of records to fetch. If this is 0
or negative an empty list is returned, the cursor is
untouched. If this is greater than the number of remaining
records, then all remaining records are returned.DataAccessException
- if something went wrong executing the queryR fetchOne() throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
The resulting record is attached to the original Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
null
if there is
no next record.DataAccessException
- if something went wrong executing the query<H extends RecordHandler<? super R>> H fetchOneInto(H handler) throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
The resulting record is attached to the original Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
handler
- The handler callbackDataAccessException
- if something went wrong executing the query<H extends RecordHandler<? super R>> H fetchInto(H handler) throws DataAccessException
The resulting records are attached to the original Configuration
by default. Use Settings.isAttachRecords()
to override this
behaviour.
handler
- The handler callbackDataAccessException
- if something went wrong executing the query<E> E fetchOne(RecordMapper<? super R,E> mapper) throws DataAccessException
This will conveniently close the Cursor
, after the last
Record
was fetched.
mapper
- The mapper callbackDataAccessException
- if something went wrong executing the query<E> java.util.List<E> fetch(RecordMapper<? super R,E> mapper) throws DataAccessException
mapper
- The mapper callbackDataAccessException
- if something went wrong executing the query<E> E fetchOneInto(java.lang.Class<? extends E> type) throws DataAccessException, MappingException
This is the same as calling fetchOne().into(type)
. See
Record.into(Class)
for more details
E
- The generic entity type.type
- The entity type.DataAccessException
- if something went wrong executing the queryMappingException
- wrapping any reflection or data type conversion
exception that might have occurred while mapping recordsRecord.into(Class)
,
Result.into(Class)
,
DefaultRecordMapper
<E> java.util.List<E> fetchInto(java.lang.Class<? extends E> type) throws DataAccessException, MappingException
This is the same as calling fetch().into(type)
. See
Record.into(Class)
for more details
E
- The generic entity type.type
- The entity type.DataAccessException
- if something went wrong executing the queryMappingException
- wrapping any reflection or data type conversion
exception that might have occurred while mapping recordsRecord.into(Class)
,
Result.into(Class)
,
DefaultRecordMapper
<Z extends Record> Z fetchOneInto(Table<Z> table) throws DataAccessException, MappingException
This is the same as calling fetchOne().into(table)
. See
Record.into(Class)
for more details
The resulting record is attached to the original Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
Z
- The generic table record type.table
- The table type.DataAccessException
- if something went wrong executing the queryMappingException
- wrapping any reflection or data type conversion
exception that might have occurred while mapping recordsRecord.into(Class)
,
Result.into(Class)
<Z extends Record> Result<Z> fetchInto(Table<Z> table) throws DataAccessException, MappingException
This is the same as calling fetch().into(table)
. See
Record.into(Class)
for more details
The result and its contained records are attached to the original
Configuration
by default. Use Settings.isAttachRecords()
to override this behaviour.
Z
- The generic table record type.table
- The table type.DataAccessException
- if something went wrong executing the queryMappingException
- wrapping any reflection or data type conversion
exception that might have occurred while mapping recordsRecord.into(Class)
,
Result.into(Class)
void close() throws DataAccessException
PreparedStatement
and
ResultSet
.
If you fetch all records from the underlying ResultSet
, jOOQ
Cursor
implementations will close themselves for you.
Calling close()
again will have no effect.
DataAccessException
- if something went wrong executing the queryboolean isClosed()
Cursor
has been explicitly or
"conveniently" closed.
Explicit closing can be achieved by calling close()
from client
code. "Convenient" closing is done by any of the other methods, when the
last record was fetched.
java.sql.ResultSet resultSet()
Cursor
's underlying ResultSet
.
This will return a ResultSet
wrapping the JDBC driver's
ResultSet
. Closing this ResultSet
may close the
producing Statement
or PreparedStatement
, depending on
your setting for ResultQuery.keepStatement(boolean)
.
Modifying this ResultSet
will affect this
Cursor
.
ResultSet
. May be null
,
for instance when the Cursor
is closed.Copyright © 2015. All Rights Reserved.