Class HibernateCreditDao
- java.lang.Object
- org.springframework.batch.sample.domain.trade.internal.HibernateCreditDao
- All Implemented Interfaces:
RepeatListener,CustomerCreditDao
public class HibernateCreditDao extends java.lang.Object implements CustomerCreditDao, RepeatListener
- Author:
- Lucas Ward, Dave Syer
Constructor Summary
Constructors Constructor Description HibernateCreditDao()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafter(RepeatContext context, RepeatStatus result)Called by the framework after each item has been processed, unless the item processing results in an exception.voidbefore(RepeatContext context)Called by the framework before each batch item.voidclose(RepeatContext context)Called once at the end of a complete batch, after normal or abnormal completion (i.e.java.util.List<java.lang.Throwable>getErrors()Public accessor for the errors property.voidonError(RepeatContext context, java.lang.Throwable e)Called when a repeat callback fails by throwing an exception.voidopen(RepeatContext context)Called once at the start of a complete batch, before any items are processed.voidsetFailOnFlush(int failOnFlush)Public setter for the failOnFlush property.voidsetSessionFactory(org.hibernate.SessionFactory sessionFactory)voidwrite(java.lang.Object output)voidwriteCredit(CustomerCredit customerCredit)
Method Detail
setSessionFactory
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
getErrors
public java.util.List<java.lang.Throwable> getErrors()
Public accessor for the errors property.- Returns:
- the errors - a list of Throwable instances
writeCredit
public void writeCredit(CustomerCredit customerCredit)
- Specified by:
writeCreditin interfaceCustomerCreditDao
write
public void write(java.lang.Object output)
setFailOnFlush
public void setFailOnFlush(int failOnFlush)
Public setter for the failOnFlush property.- Parameters:
failOnFlush- the ID of the record you want to fail on flush (for testing)
onError
public void onError(RepeatContext context, java.lang.Throwable e)
Description copied from interface:RepeatListenerCalled when a repeat callback fails by throwing an exception. There will be one call to this method for each exception thrown during a repeat operation (e.g. a chunk).
There is no need to re-throw the exception here - that will be done by the enclosing framework.- Specified by:
onErrorin interfaceRepeatListener- Parameters:
context- the current batch contexte- the error that was encountered in an item callback.
after
public void after(RepeatContext context, RepeatStatus result)
Description copied from interface:RepeatListenerCalled by the framework after each item has been processed, unless the item processing results in an exception. This method is called as soon as the result is known.- Specified by:
afterin interfaceRepeatListener- Parameters:
context- the current batch contextresult- the result of the callback
before
public void before(RepeatContext context)
Description copied from interface:RepeatListenerCalled by the framework before each batch item. Implementers can halt a batch by setting the complete flag on the context.- Specified by:
beforein interfaceRepeatListener- Parameters:
context- the current batch context.
close
public void close(RepeatContext context)
Description copied from interface:RepeatListenerCalled once at the end of a complete batch, after normal or abnormal completion (i.e. even after an exception). Implementers can use this method to clean up any resources.- Specified by:
closein interfaceRepeatListener- Parameters:
context- the current batch context.
open
public void open(RepeatContext context)
Description copied from interface:RepeatListenerCalled once at the start of a complete batch, before any items are processed. Implementers can use this method to acquire any resources that might be needed during processing. Implementers can halt the current operation by setting the complete flag on the context. To halt all enclosing batches (the whole job), the would need to use the parent context (recursively).- Specified by:
openin interfaceRepeatListener- Parameters:
context- the current batch context