Spring Batch - Last item from the reader alone is getting updated
<p>I have to read from a file (FlatFile) and update a column if that ID present in the file matches the id in the column.The file is being read properly but only the last id value is getting updated here . Please find the snippet</p>

<p>Job-Config.xml </p>

<pre><code>&lt;bean id="abcitemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"&gt;
        &lt;property name="resource" value="file:datafile/outputs/ibdData.txt" /&gt;
    &lt;property name="lineMapper"&gt;
        &lt;bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"&gt;          
          &lt;property name="lineTokenizer"&gt;
                &lt;bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"&gt;
                &lt;property name="names" value="ID,NAM,TYPE" /&gt;
                &lt;property name="delimiter" value="|"/&gt;
            &lt;/bean&gt;
          &lt;/property&gt;
          &lt;property name="fieldSetMapper"&gt;  
          &lt;bean class="com.pershing.intraware.springbatch.mapper.abcFieldsetMapper" /&gt;           
          &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
    &lt;/bean&gt; 

    &lt;bean id="abcitemWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter" scope="step"&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt; 
    &lt;property name="sql"&gt;&lt;value&gt;UPDATE TEST_abc SET BIZ_ARNG_CD = CASE WHEN ID IN (SELECT ID FROM TEST_abc WHERE ID= ? and MONTH=(to_char(sysdate, 'MM')) AND  YR =(to_char(sysdate, 'YY'))) THEN 'Y' ELSE 'N' END&lt;/value&gt;&lt;/property&gt;
    &lt;!-- It will take care matching between object property and sql name parameter --&gt;
    &lt;property name="itemPreparedStatementSetter" ref="testPrepStatementSetter" /&gt; 
&lt;/bean&gt;
&lt;/beans&gt;
</code></pre>

<p>Setter.java</p>

<pre><code>public class IDItemPreparedStatementSetter implements ItemPreparedStatementSetter&lt;Test&gt;  {
  @Override
  public void setValues(Test item, PreparedStatement ps) throws SQLException {
    // TODO Auto-generated method stub
    ps.setString(1, item.getID());
  }     
}
</code></pre>