title: How does Spring Batch transaction management work?
body: <p>I'm trying to understand how Spring Batch does transaction management. This is not a technical question but more of conceptual one: what approach does Spring Batch use and what are the consequences of that approach?</p>
  
  <p>Let me try to clarify this question a bit. For instance, looking at the TaskletStep, I see that generally a step execution looks something like this:</p>
  
  <ol>
  <li>several <em>JobRepository transactions</em> to prepare the step metadata</li>
  <li>a <em>business transaction</em> for every chunk to process</li>
  <li>more <em>JobRepository transactions</em> to update the step metadata with the results of chunk processing</li>
  </ol>
  
  <p>This seems to make sense. But what about a failure between 2 and 3? This would mean the business transaction was committed but Spring Batch was unable to record that fact in its internal metadata. So a restart would reprocess the same items again even though they have already been committed. Right?</p>
  
  <p>I'm looking for an explanation of these details and the consequences of the design decisions made in Spring Batch. Is this documented somewhere? The Spring Batch reference guide has very few details on this. It simply explains things from the application developer's point of view.</p>