class HibernateCreditDao implements CustomerCreditDao, RepeatListener {

	private int failOnFlush = -1;

	private final List<Throwable> errors = new ArrayList<>();

	private SessionFactory sessionFactory;

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

	/**
	 * Public accessor for the errors property.
	 * @return the errors - a list of Throwable instances
	 */
	public List<Throwable> getErrors() {
		return errors;
	}

	@Override
	public void writeCredit(CustomerCredit customerCredit) {<FILL_FUNCTION_BODY>}

	public void write(Object output) {
		writeCredit((CustomerCredit) output);
	}

	/**
	 * Public setter for the failOnFlush property.
	 * @param failOnFlush the ID of the record you want to fail on flush (for testing)
	 */
	public void setFailOnFlush(int failOnFlush) {
		this.failOnFlush = failOnFlush;
	}

	@Override
	public void onError(RepeatContext context, Throwable e) {
		errors.add(e);
	}

	@Override
	public void after(RepeatContext context, RepeatStatus result) {
	}

	@Override
	public void before(RepeatContext context) {
	}

	@Override
	public void close(RepeatContext context) {
	}

	@Override
	public void open(RepeatContext context) {
	}

}

		if (customerCredit.getId() == failOnFlush) {
			// try to insert one with a duplicate ID
			CustomerCredit newCredit = new CustomerCredit();
			newCredit.setId(customerCredit.getId());
			newCredit.setName(customerCredit.getName());
			newCredit.setCredit(customerCredit.getCredit());
			sessionFactory.getCurrentSession().save(newCredit);
		}
		else {
			sessionFactory.getCurrentSession().update(customerCredit);
		}
	
<no_super_class>