class ItemTrackingTradeItemWriter implements ItemWriter<Trade> {

	private final List<Trade> items = new ArrayList<>();

	private String writeFailureISIN;

	private JdbcOperations jdbcTemplate;

	public void setDataSource(DataSource dataSource) {
		jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public void setWriteFailureISIN(String writeFailureISIN) {
		this.writeFailureISIN = writeFailureISIN;
	}

	public List<Trade> getItems() {
		return items;
	}

	@Override
	public void write(Chunk<? extends Trade> items) throws Exception {<FILL_FUNCTION_BODY>}

}

		List<Trade> newItems = new ArrayList<>();

		for (Trade t : items) {
			if (t.getIsin().equals(this.writeFailureISIN)) {
				throw new IOException("write failed");
			}

			newItems.add(t);

			if (jdbcTemplate != null) {
				jdbcTemplate.update("UPDATE TRADE set VERSION=? where ID=? and version=?", t.getVersion() + 1,
						t.getId(), t.getVersion());
			}
		}

		this.items.addAll(newItems);
	
<no_super_class>