class StagingItemWriter<T> extends JdbcDaoSupport implements StepExecutionListener, ItemWriter<T> {

	protected static final String NEW = "N";

	protected static final String DONE = "Y";

	private DataFieldMaxValueIncrementer incrementer;

	private StepExecution stepExecution;

	/**
	 * Check mandatory properties.
	 *
	 * @see org.springframework.dao.support.DaoSupport#initDao()
	 */
	@Override
	protected void initDao() throws Exception {
		super.initDao();
		Assert.notNull(incrementer, "DataFieldMaxValueIncrementer is required - set the incrementer property in the "
				+ ClassUtils.getShortName(StagingItemWriter.class));
	}

	/**
	 * Setter for the key generator for the staging table.
	 * @param incrementer the {@link DataFieldMaxValueIncrementer} to set
	 */
	public void setIncrementer(DataFieldMaxValueIncrementer incrementer) {
		this.incrementer = incrementer;
	}

	/**
	 * Serialize the item to the staging table, and add a NEW processed flag.
	 *
	 * @see ItemWriter#write(Chunk)
	 */
	@Override
	public void write(final Chunk<? extends T> chunk) {<FILL_FUNCTION_BODY>}

	@Nullable
	@Override
	public ExitStatus afterStep(StepExecution stepExecution) {
		return null;
	}

	@Override
	public void beforeStep(StepExecution stepExecution) {
		this.stepExecution = stepExecution;
	}

}

		final ListIterator<? extends T> itemIterator = chunk.getItems().listIterator();

		getJdbcTemplate().batchUpdate("INSERT into BATCH_STAGING (ID, JOB_ID, VALUE, PROCESSED) values (?,?,?,?)",
				new BatchPreparedStatementSetter() {
					@Override
					public int getBatchSize() {
						return chunk.size();
					}

					@Override
					public void setValues(PreparedStatement ps, int i) throws SQLException {
						Assert.state(itemIterator.nextIndex() == i,
								"Item ordering must be preserved in batch sql update");

						ps.setLong(1, incrementer.nextLongValue());
						ps.setLong(2, stepExecution.getJobExecution().getJobId());
						ps.setBytes(3, SerializationUtils.serialize(itemIterator.next()));
						ps.setString(4, NEW);
					}
				});
	
<methods>public void <init>() ,public final javax.sql.DataSource getDataSource() ,public final org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate() ,public final void setDataSource(javax.sql.DataSource) ,public final void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) <variables>private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate