public class IbatisPagingItemReader<T> extends AbstractPagingItemReader<T>
ItemReader for reading database
records using iBATIS in a paging fashion.
It executes the query specified as the setQueryId(String) to
retrieve requested data. The query is executed using paged requests of a size
specified in AbstractPagingItemReader.setPageSize(int). Additional pages are requested when
needed as AbstractItemCountingItemStreamItemReader.read() method is called, returning an object corresponding
to current position. Some standard query parameters are provided by the
reader and the SQL in the named query must use some or all of these parameters
(depending on the SQL variant) to construct a result set of the required
size. The parameters are:
_page: the page number to be read (starting at 0)_pagesize: the size of the pages, i.e. the number of rows to
return_skiprows: the product of _page and
_pagesizeThe performance of the paging depends on the iBATIS implementation. Setting a fairly large page size and using a commit interval that matches the page size should provide better performance.
The implementation is thread-safe in between calls to
AbstractItemCountingItemStreamItemReader.open(ExecutionContext), but remember to use
saveState=false if used in a multi-threaded client (no restart
available).
logger, results| Constructor and Description |
|---|
IbatisPagingItemReader() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Check mandatory properties.
|
protected void |
doJumpToPage(int itemIndex) |
protected void |
doReadPage() |
void |
setParameterValues(Map<String,Object> parameterValues)
The parameter values to be used for the query execution.
|
void |
setQueryId(String queryId) |
void |
setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient) |
doClose, doOpen, doRead, getPage, getPageSize, jumpToItem, setPageSizeclose, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, updategetExecutionContextKey, setExecutionContextName, setNamepublic void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
public void setQueryId(String queryId)
public void setParameterValues(Map<String,Object> parameterValues)
parameterValues - the values keyed by the parameter named used in
the query string.public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanafterPropertiesSet in class AbstractPagingItemReader<T>ExceptionInitializingBean.afterPropertiesSet()protected void doReadPage()
doReadPage in class AbstractPagingItemReader<T>protected void doJumpToPage(int itemIndex)
doJumpToPage in class AbstractPagingItemReader<T>Copyright © 2014 Pivotal. All rights reserved.