class HibernateAwareCustomerCreditItemWriter implements ItemWriter<CustomerCredit>, InitializingBean {

	private CustomerCreditDao dao;

	private SessionFactory sessionFactory;

	@Override
	public void write(Chunk<? extends CustomerCredit> items) throws Exception {
		for (CustomerCredit credit : items) {
			dao.writeCredit(credit);
		}
		try {
			sessionFactory.getCurrentSession().flush();
		}
		finally {
			// this should happen automatically on commit, but to be on the safe
			// side...
			sessionFactory.getCurrentSession().clear();
		}

	}

	public void setDao(CustomerCreditDao dao) {
		this.dao = dao;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	@Override
	public void afterPropertiesSet() throws Exception {<FILL_FUNCTION_BODY>}

}

		Assert.state(sessionFactory != null, "Hibernate SessionFactory is required");
		Assert.state(dao != null, "Delegate DAO must be set");
	
<no_super_class>