title: Spring Batch : Write a List to a database table using a custom batch size
body: <p><strong>Background</strong></p>
  
  <p>I have a  <em>Spring Batch</em> job where :</p>
  
  <ol>
  <li><code>FlatFileItemReader</code> - Reads one row at a time from the file</li>
  <li><code>ItemProcesor</code> - Transforms the row from the file into a <code>List&lt;MyObject&gt;</code> and returns the <code>List</code>. That is, each row in the file is broken down into a <code>List&lt;MyObject&gt;</code> (1 row in file transformed to many output rows).</li>
  <li><code>ItemWriter</code> - Writes the <code>List&lt;MyObject&gt;</code> to a database table. (I used <a href="https://stackoverflow.com/a/37866590/6043279">this</a>
  implementation to unpack the list received from the processor
  and delegae to a <code>JdbcBatchItemWriter</code>)</li>
  </ol>
  
  <p><strong>Question</strong></p>
  
  <ul>
  <li>At point 2) The processor can return a <code>List</code> of 100000  <code>MyObject</code> instances.</li>
  <li>At point 3), The delegate <code>JdbcBatchItemWriter</code> will end up writing the entire <code>List</code> with 100000 objects to the database. </li>
  </ul>
  
  <p>My question is : The <code>JdbcBatchItemWriter</code> does not allow  a custom batch size. For all practical purposes, the batch-size = commit-interval for the step. With this in mind, <strong>is there another implementation of an <code>ItemWriter</code> available in <em>Spring Batch</em> that allows writing to the database and allows configurable batch size? If not, how do go about writing a custom writer myself to acheive this?</strong></p>