R
- The mapped result type.public class PagingJdbcIterable<R> extends Object implements Iterable<R>
PagingJdbcIterable.PagingStatementSupplier
, fetching the next page when the items run out to iterate through.
Do not use this for paging when you care about concurrent deletes. If you loaded a page, delete an item from it, and load the next, you will miss an item during iteration.
The iterator()
function can be called multiple times to loop through the items, restarting the query from
the start.
Modifier and Type | Class and Description |
---|---|
class |
PagingJdbcIterable.PagingIterator
The
Iterator that loops through the provided query's pages until it runs out of items. |
static interface |
PagingJdbcIterable.PagingStatementSupplier
Describes a function that creates a new
PreparedStatement that pages results through the given
offset and maxSize , ready to be executed. |
Constructor and Description |
---|
PagingJdbcIterable(TransactionManager transactionManager,
Supplier<Connection> connectionProvider,
PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier,
int pageSize,
JdbcUtils.SqlResultConverter<R> resultConverter,
Function<SQLException,RuntimeException> errorHandler)
Construct a new
Iterable of type R , utilizing paging queries to retrieve the entries. |
Modifier and Type | Method and Description |
---|---|
Iterator<R> |
iterator() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public PagingJdbcIterable(TransactionManager transactionManager, Supplier<Connection> connectionProvider, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException,RuntimeException> errorHandler)
Iterable
of type R
, utilizing paging queries to retrieve the entries.transactionManager
- The TransactionManager
used to execute the paging query.connectionProvider
- The supplier of the Connection
used by the given pagingQuerySupplier
.pagingQuerySupplier
- A factory function supply the paging PreparedStatement
to execute.pageSize
- The size of the pages to retrieve. Used to calculate the offset
and
maxSize
of the paging queryresultConverter
- The converter of the ResultSet
into entries of type R
.errorHandler
- The error handler to deal with exceptions when executing a paging
PreparedStatement
.Copyright © 2010–2024. All rights reserved.