public void write(List<? extends Trade> items) throws Exception { List<Trade> newItems = new ArrayList<Trade>(); 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); }