public class HibernateItemWriter<T> extends Object implements ItemWriter<T>, org.springframework.beans.factory.InitializingBean
ItemWriter
that uses a Hibernate session to save or update entities
that are not part of the current Hibernate session. It will also flush the
session after writing (i.e. at chunk boundaries if used in a Spring Batch
TaskletStep). It will also clear the session on write
default (see clearSession
property).Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
HibernateItemWriter() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Check mandatory properties - there must be a hibernateTemplate.
|
protected void |
doWrite(org.springframework.orm.hibernate3.HibernateOperations hibernateTemplate,
List<? extends T> items)
Do perform the actual write operation.
|
void |
setClearSession(boolean clearSession)
Flag to indicate that the session should be cleared and flushed at the
end of the write (default true).
|
void |
setHibernateTemplate(org.springframework.orm.hibernate3.HibernateOperations hibernateTemplate)
Public setter for the
HibernateOperations property. |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Set the Hibernate SessionFactory to be used internally.
|
void |
write(List<? extends T> items)
Save or update any entities not in the current hibernate session and then
flush the hibernate session.
|
public void setClearSession(boolean clearSession)
clearSession
- the flag value to setpublic void setHibernateTemplate(org.springframework.orm.hibernate3.HibernateOperations hibernateTemplate)
HibernateOperations
property.hibernateTemplate
- the hibernateTemplate to setpublic final void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public final void write(List<? extends T> items)
write
in interface ItemWriter<T>
ItemWriter.write(java.util.List)
protected void doWrite(org.springframework.orm.hibernate3.HibernateOperations hibernateTemplate, List<? extends T> items)
hibernateTemplate
- the HibernateTemplate to use for the operationitems
- the list of items to use for the writeCopyright © 2013 SpringSource. All rights reserved.