title: How to make Execution context in Spring batch Partitioner to run in sequence
body: <p>I have a requirement where first I have to select no of MasterRecords from table and then for each MasterRecords I will have to fetch no of child rows and for each child rows process and write chunk wise.</p>
  
  <p>To do this I used Partitioner in spring batch and created master and slave steps to achieve this. Now code is working fine if I dont need to run slave step in same sequence it was added to Execution context.</p>
  
  <p>But <strong>my requirement is to run slave step for each execution context in same sequence it was added in partitioner</strong>. Because until I process parent record I cannot process child records. 
  Using partitioner slave step is not running in same sequence. Please help me how to maintain same sequence for slave step  run ?????</p>
  
  <p>Is there any other way to achieve this using spring batch. any help is welcomed.</p>
  
  <pre><code>    &lt;job id="EPICSDBJob" xmlns="http://www.springframework.org/schema/batch"&gt;
              &lt;!-- Create Order Master Start --&gt;
              &lt;step id="populateNewOrdersMasterStep" allow-start-if-complete="false"
                  next="populateLineItemMasterStep"&gt;
                  &lt;partition step="populateNewOrders" partitioner="pdcReadPartitioner"&gt;
                      &lt;handler grid-size="1" task-executor="taskExecutor" /&gt;
                  &lt;/partition&gt;
                  &lt;batch:listeners&gt;
                      &lt;batch:listener ref="partitionerStepListner" /&gt;
                  &lt;/batch:listeners&gt;
              &lt;/step&gt;
              &lt;!-- Create Order Master End --&gt;
  
              &lt;listeners&gt;
                  &lt;listener ref="epicsPimsJobListner" /&gt;
              &lt;/listeners&gt;
          &lt;/job&gt;
  
      &lt;step id="populateNewOrders" xmlns="http://www.springframework.org/schema/batch"&gt;
              &lt;tasklet allow-start-if-complete="true"&gt;
                  &lt;chunk reader="epicsDBReader" processor="epicsPimsProcessor"
                      writer="pimsWriter" commit-interval="10"&gt;
                  &lt;/chunk&gt;
              &lt;/tasklet&gt;
              &lt;batch:listeners&gt;
                  &lt;batch:listener ref="stepJobListner" /&gt;
              &lt;/batch:listeners&gt;
          &lt;/step&gt;
  &lt;bean id="epicsDBReader" class="com.cat.epics.sf.batch.reader.EPICSDBReader" scope="step" &gt;
          &lt;property name="sfObjName" value="#{stepExecutionContext[sfParentObjNm]}" /&gt;
          &lt;property name="readChunkCount" value="10" /&gt;
          &lt;property name="readerDao" ref="readerDao" /&gt;
          &lt;property name="configDao" ref="configDao" /&gt;
          &lt;property name="dBReaderService" ref="dBReaderService" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Partitioner Method:</p>
  
  <pre><code>@Override
  public Map&lt;String, ExecutionContext&gt; partition(int arg0) {
      Map&lt;String, ExecutionContext&gt; result  = new LinkedHashMap&lt;String, ExecutionContext&gt;();
      List&lt;String&gt; sfMappingObjectNames = configDao.getSFMappingObjNames();
      int i=1;
      for(String sfMappingObjectName: sfMappingObjectNames){
          ExecutionContext value = new ExecutionContext();
          value.putString("sfParentObjNm", sfMappingObjectName);          
          result.put("partition:"+i, value);
          i++;
      }
      return result;
  }
  </code></pre>