org.springframework.batch.item.database
Class IbatisPagingItemReader<T>
java.lang.Object
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
org.springframework.batch.item.database.AbstractPagingItemReader<T>
org.springframework.batch.item.database.IbatisPagingItemReader<T>
- All Implemented Interfaces:
- ItemReader<T>, ItemStream, ItemStreamReader<T>, InitializingBean
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
_pagesize
Failure to write the correct platform-specific SQL often results in an
infinite loop in the reader because it keeps asking for the next page and
gets the same result set over and over.
The 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).
- Since:
- 2.0
- Author:
- Thomas Risberg, Dave Syer
Methods inherited from class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader |
close, getCurrentItemCount, getExecutionContextUserSupport, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setName, setSaveState, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IbatisPagingItemReader
public IbatisPagingItemReader()
setSqlMapClient
public void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
setQueryId
public void setQueryId(String queryId)
setParameterValues
public void setParameterValues(Map<String,Object> parameterValues)
- The parameter values to be used for the query execution.
- Parameters:
parameterValues
- the values keyed by the parameter named used in
the query string.
afterPropertiesSet
public void afterPropertiesSet()
throws Exception
- Check mandatory properties.
- Specified by:
afterPropertiesSet
in interface InitializingBean
- Overrides:
afterPropertiesSet
in class AbstractPagingItemReader<T>
- Throws:
Exception
- See Also:
InitializingBean.afterPropertiesSet()
doReadPage
protected void doReadPage()
- Specified by:
doReadPage
in class AbstractPagingItemReader<T>
doJumpToPage
protected void doJumpToPage(int itemIndex)
- Specified by:
doJumpToPage
in class AbstractPagingItemReader<T>
Copyright © 2013 SpringSource. All Rights Reserved.