Package org.axonframework.common.jdbc
Class PagingJdbcIterable<R>
java.lang.Object
org.axonframework.common.jdbc.PagingJdbcIterable<R>
- Type Parameters:
R- The mapped result type.
- All Implemented Interfaces:
Iterable<R>
Enables iterating through a JDBC query using paging. Paging is taken care of automatically through the provided
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.
- Since:
- 4.8.0
- Author:
- Mitchell Herrijgers, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassTheIteratorthat loops through the provided query's pages until it runs out of items.static interfaceDescribes a function that creates a newPreparedStatementthat pages results through the givenoffsetandmaxSize, ready to be executed. -
Constructor Summary
ConstructorsConstructorDescriptionPagingJdbcIterable(TransactionManager transactionManager, Supplier<Connection> connectionProvider, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagingJdbcIterable
public PagingJdbcIterable(TransactionManager transactionManager, Supplier<Connection> connectionProvider, PagingJdbcIterable.PagingStatementSupplier pagingQuerySupplier, int pageSize, JdbcUtils.SqlResultConverter<R> resultConverter, Function<SQLException, RuntimeException> errorHandler) Construct a newIterableof typeR, utilizing paging queries to retrieve the entries.- Parameters:
transactionManager- TheTransactionManagerused to execute the paging query.connectionProvider- The supplier of theConnectionused by the givenpagingQuerySupplier.pagingQuerySupplier- A factory function supply the pagingPreparedStatementto execute.pageSize- The size of the pages to retrieve. Used to calculate theoffsetandmaxSizeof the paging queryresultConverter- The converter of theResultSetinto entries of typeR.errorHandler- The error handler to deal with exceptions when executing a pagingPreparedStatement.
-
-
Method Details