|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
org.springframework.batch.item.database.HibernateCursorItemReader<T>
public class HibernateCursorItemReader<T>
ItemReader for reading database records built on top of Hibernate. It
executes the HQL query when initialized iterates over the result set as
AbstractItemCountingItemStreamItemReader.read() method is called, returning an object corresponding to
current row. The query can be set directly using
setQueryString(String) or a named query can be used by
setQueryName(String).
The reader can be configured to use either StatelessSession
sufficient for simple mappings without the need to cascade to associated
objects or standard hibernate Session for more advanced mappings or
when caching is desired. When stateful session is used it will be cleared in
the update(ExecutionContext) method without being flushed (no data
modifications are expected).
| Constructor Summary | |
|---|---|
HibernateCursorItemReader()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
protected void |
doClose()
Close the cursor and hibernate session. |
protected void |
doOpen()
Open hibernate session and create a forward-only cursor for the setQueryString(String). |
protected T |
doRead()
Read next item from input. |
protected void |
jumpToItem(int itemIndex)
Move to the given item index. |
void |
setFetchSize(int fetchSize)
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object. |
void |
setQueryName(java.lang.String queryName)
|
void |
setQueryString(java.lang.String queryString)
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
|
void |
setUseStatelessSession(boolean useStatelessSession)
Can be set only in uninitialized state. |
void |
update(ExecutionContext executionContext)
Clears the session if not stateful and delegates to super class. |
| Methods inherited from class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader |
|---|
close, getCurrentItemCount, open, read, setCurrentItemCount, setMaxItemCount, setName, setSaveState |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.springframework.batch.item.ItemStream |
|---|
close, open |
| Constructor Detail |
|---|
public HibernateCursorItemReader()
| Method Detail |
|---|
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory - hibernate session factory
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void setQueryName(java.lang.String queryName)
queryName - name of a hibernate named querypublic void setQueryString(java.lang.String queryString)
queryString - HQL query stringpublic void setUseStatelessSession(boolean useStatelessSession)
useStatelessSession - true to use
StatelessSession false to use standard hibernate
Session
public void update(ExecutionContext executionContext)
throws ItemStreamException
update in interface ItemStreamupdate in class AbstractItemCountingItemStreamItemReader<T>executionContext - to be updated
ItemStreamExceptionpublic void setFetchSize(int fetchSize)
ResultSet object. If the fetch size specified is zero, the
JDBC driver ignores the value.
fetchSize - the number of rows to fetch, 0 by defaultQuery.setFetchSize(int)
protected T doRead()
throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doRead in class AbstractItemCountingItemStreamItemReader<T>java.lang.Exception
protected void doOpen()
throws java.lang.Exception
setQueryString(String).
doOpen in class AbstractItemCountingItemStreamItemReader<T>java.lang.Exception
protected void jumpToItem(int itemIndex)
throws java.lang.Exception
AbstractItemCountingItemStreamItemReaderAbstractItemCountingItemStreamItemReader.doRead().
jumpToItem in class AbstractItemCountingItemStreamItemReader<T>java.lang.Exception
protected void doClose()
throws java.lang.Exception
doClose in class AbstractItemCountingItemStreamItemReader<T>java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||