title: Spring Batch how to write a Map
body: <p>i've already seen a lot of tutorials and spring material but i have found only examples that contains a simple object in the ItemWriter.</p>
  
  <p>For example...</p>
  
  <pre><code>    @Bean
      JdbcBatchItemWriter&lt;Student&gt; writer = new JdbcBatchItemWriter&lt;&gt;();
      writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider&lt;Student&gt;());
      writer.setItemPreparedStatementSetter(new ItemPreparedStatementSetter&lt;Student&gt;(){
          @Override
          public void setValues(Student student, PreparedStatement ps) throws SQLException {
              ps.setLong(1,student.getStudentCode());
              ps.setObject(2,student.getStudentGrade());
          }});
      writer.setSql(QUERY_STUDENT_GRADE_INSERT);
      writer.setDataSource(dataSource);
      return writer;  
  </code></pre>
  
  <p>in my actual scenario i must write a Map that contains a key and a value like:</p>
  
  <pre><code>Map&lt;KeyObject,Long&gt;
  </code></pre>
  
  <p>But i have no idea how to code something that be able to insert all the content that i've received in my Map.</p>
  
  <p>There's another question...</p>
  
  <p>When i process certain number of items i need to store this data in the database, but the previous content stay in my collection, that way... how can i clean the map content after write ?</p>