title: spring batch not rolling on runtime exception in itemwriter
body: <p>I am new to spring batch and I have a spring batch with spring data project with oracle database. Basically for simplicity I have 2 steps :</p>
  
  <p>Step 1 : Read the first row of the csv file than insert in table_header in itemwriter </p>
  
  <p>Step 2 : Read from the  second row of the csv file than insert in table_detail in itemwriter.</p>
  
  <p>The table_header is linked to table_detail - one to many relationship.</p>
  
  <p>Basically if a runtime exception in triggered in step 2 just after saving the detail while in the same step the data does not roll back.According to spring reference it should roll back on runtime exception.</p>
  
  <p>I am not sure what i am missing in order for the transaction to rollback, can someone point me to the right direction pls?</p>
  
  <p>Please find below my database configuration:</p>
  
  <pre><code>@Configuration
  @EnableTransactionManagement
  @EnableJpaRepositories(entityManagerFactoryRef = "dummyEntityManager", transactionManagerRef = "dummyTransactionManager", basePackages = {
          "com.dummy.persistence" })
  @PropertySource("file:${test_PROPERTIES}")
  public class DatabaseConfig extends HikariConfig {
  
  
      @Bean(name = "dummyDatasource")
      public HikariDataSource dataSource() {
          HikariDataSource hikariDataSource = new HikariDataSource();
          hikariDataSource.setJdbcUrl(CipherWrapper.getInstance().decrypt(jdbcUrl));
          hikariDataSource.setUsername(CipherWrapper.getInstance().decrypt(username));
          hikariDataSource.setPassword(CipherWrapper.getInstance().decrypt(password));
          hikariDataSource.setAutoCommit(false);
          hikariDataSource.setMaximumPoolSize(maximumPoolSize);
          hikariDataSource.setMinimumIdle(minimumIdle);
          return hikariDataSource;
      }
  
  
      @Bean(name = "dummyEntityManager")
      public LocalContainerEntityManagerFactoryBean dummyEntityManagerFactory(EntityManagerFactoryBuilder builder) {
          LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = builder.dataSource(dataSource())
                  .packages("com.dummy.persistence.entity").persistenceUnit("dummyPersistenceUnit").build();
  
          localContainerEntityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
  
  
          return localContainerEntityManagerFactoryBean;
      }
  
  
      @Bean(name = "dummyTransactionManager")
      public PlatformTransactionManager dummyTransactionManager(
              @Qualifier("dummyEntityManager") EntityManagerFactory dummyEntityManagerFactory) {
          JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(dummyEntityManagerFactory);
          jpaTransactionManager.setRollbackOnCommitFailure(true);
          return jpaTransactionManager;
      }
  
  
  @Bean
  public BatchConfigurer batchConfigurer(@Qualifier("dummyEntityManager") EntityManagerFactory dummyEntityManagerFactory) {
          return new DefaultBatchConfigurer() {
                  @Override
                  public PlatformTransactionManager getTransactionManager() {
                          return  dummyTransactionManager(dummyTransactionManager);
                  }
          };
  }
  }
  </code></pre>
  
  <p>Please find below both step config:</p>
  
  <pre><code>@Bean("step1")
  public Step headerSaveStep() {
  
  StepBuilder stepBuilder = stepBuilderFactory.get(Flow.STEP1.toString());
  SimpleStepBuilder&lt;HeaderDetailsDto,HeaderDetailsAdditionaDto&gt; simpleStepBuilder = stepBuilder
          .&lt;HeaderDetailsDto, HeaderDetailsAdditionaDto&gt;chunk(1);
  simpleStepBuilder.reader(csvItemReader.csvFileVatPayerDetailsItemReader(null));
  simpleStepBuilder.processor(EnrichmentProcessor());
  simpleStepBuilder.writer(headerWriter());
  simpleStepBuilder.allowStartIfComplete(true);
  return simpleStepBuilder.build();
  </code></pre>
  
  <p>}</p>
  
  <pre><code>@Bean("step2")
  public Step detailSaveStep() {
  
  StepBuilder stepBuilder = stepBuilderFactory.get(Flow.STEP2.toString());
  SimpleStepBuilder&lt;DetailsDto, DetailsDto&gt; simpleStepBuilder = stepBuilder
          .&lt;DetailsDto, DetailsDto&gt;chunk(20000);
  simpleStepBuilder.reader(csvItemReader.csvFileBuyerDetailsFileItemReader(null));
  simpleStepBuilder.writer(detailsWriter());
  simpleStepBuilder.allowStartIfComplete(true);
  return simpleStepBuilder.build();
  </code></pre>
  
  <p>}</p>