public class HibernateItemReaderHelper<T>
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean
Constructor and Description |
---|
HibernateItemReaderHelper() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
clear()
Clear the session if stateful.
|
void |
close()
Close the open session (stateful or otherwise).
|
org.hibernate.Query |
createQuery()
Open appropriate type of hibernate session and create the query.
|
org.hibernate.ScrollableResults |
getForwardOnlyCursor(int fetchSize,
java.util.Map<java.lang.String,java.lang.Object> parameterValues)
Get a cursor over all of the results, with the forward-only flag set.
|
void |
jumpToItem(org.hibernate.ScrollableResults cursor,
int itemIndex,
int flushInterval)
Scroll through the results up to the item specified.
|
java.util.Collection<? extends T> |
readPage(int page,
int pageSize,
int fetchSize,
java.util.Map<java.lang.String,java.lang.Object> parameterValues)
Read a page of data, clearing the existing session (if necessary) first,
and creating a new session before executing the query.
|
void |
setQueryName(java.lang.String queryName) |
void |
setQueryProvider(HibernateQueryProvider<? extends T> queryProvider) |
void |
setQueryString(java.lang.String queryString) |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory) |
void |
setUseStatelessSession(boolean useStatelessSession)
Can be set only in uninitialized state.
|
public void setQueryName(java.lang.String queryName)
queryName
- name of a hibernate named querypublic void setQueryString(java.lang.String queryString)
queryString
- HQL query stringpublic void setQueryProvider(HibernateQueryProvider<? extends T> queryProvider)
queryProvider
- Hibernate query providerpublic void setUseStatelessSession(boolean useStatelessSession)
useStatelessSession
- true
to use
StatelessSession
false
to use standard hibernate
Session
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- hibernate session factorypublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
public org.hibernate.ScrollableResults getForwardOnlyCursor(int fetchSize, java.util.Map<java.lang.String,java.lang.Object> parameterValues)
fetchSize
- the fetch size to use retrieving the resultsparameterValues
- the parameter values to use (or null if none).ScrollableResults
public org.hibernate.Query createQuery()
public void jumpToItem(org.hibernate.ScrollableResults cursor, int itemIndex, int flushInterval)
cursor
- the results to scroll overitemIndex
- index to scroll toflushInterval
- the number of items to scroll past before flushingpublic void close()
public java.util.Collection<? extends T> readPage(int page, int pageSize, int fetchSize, java.util.Map<java.lang.String,java.lang.Object> parameterValues)
page
- the page to read (starting at 0)pageSize
- the size of the page or maximum number of items to readfetchSize
- the fetch size to useparameterValues
- the parameter values to use (if any, otherwise
null)public void clear()