T
- The query result type.R
- The mapped result type.public class PagingJpaQueryIterable<T,R> extends Object implements Iterable<R>
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 |
PagingJpaQueryIterable.PagingIterator
The
Iterator that loops through the provided query's pages until it runs out of items. |
Constructor and Description |
---|
PagingJpaQueryIterable(int pageSize,
TransactionManager transactionManager,
Supplier<jakarta.persistence.TypedQuery<T>> querySupplier,
Function<T,R> lazyMappingFunction)
Constructs a new
Iterable using the provided querySupplier to construct queries when a new page
needs to be fetched. |
Modifier and Type | Method and Description |
---|---|
Iterator<R> |
iterator() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public PagingJpaQueryIterable(int pageSize, TransactionManager transactionManager, Supplier<jakarta.persistence.TypedQuery<T>> querySupplier, Function<T,R> lazyMappingFunction)
Iterable
using the provided querySupplier
to construct queries when a new page
needs to be fetched. Items are lazily mapped by the provided lazyMappingFunction
when iterating.pageSize
- The size of the pages.transactionManager
- The TransactionManager
to use when fetching items.querySupplier
- The supplier of the queries. Will be invoked for each page.lazyMappingFunction
- The mapping function to map items to the desired representation.Copyright © 2010–2024. All rights reserved.