title: Spring Batch JdbcBatchItemWriter setSql never throws exception
body: <p>My simple flow of batch process reads from a CSV file and write into a MySQL database (batch configuration is ok and works).</p>
  
  <p>I'm using a custom implementation of JdbcBatchItemWriter in order to do the job and I'm actually making an Update in my writer constructor.</p>
  
  <p>CsvReader.java</p>
  
  <pre><code>@Component
  @StepScope
  public class EducationCsvReader extends FlatFileItemReader {    
      public final static String CSV_FILE_NAME = "education.csv.file";
  
      @Value("#{jobParameters['"+ CSV_FILE_NAME +"']}")
      public void setResource(final String csvFileName) throws Exception {
          setResource(
                  new FileSystemResource(csvFileName)
          );
  
      }
  
      public EducationCsvReader() {
          setLinesToSkip(1);
          setEncoding("UTF-8");
          setStrict(true);
          setLineMapper((line, num) -&gt; {
              String[] values = line.split(";");
              return new Education()
                      .setName(values[2].trim())
                      .setId(Integer.parseInt(values[0].trim()));
          });
  
      }
  
  }
  </code></pre>
  
  <p>my custom JdbcBatchItemWriter : AbstractJdbcBatchItemWriter.java </p>
  
  <pre><code>public abstract class AbstractJdbcBatchItemWriter&lt;T&gt; extends JdbcBatchItemWriter&lt;T&gt;{
  
      @Autowired
      public AbstractJdbcBatchItemWriter(String SQL_QUERY) {
          setSql(SQL_QUERY);
      }
  
      @Autowired
      @Override
      public void setItemSqlParameterSourceProvider(
              @Qualifier("beanPropertyItemSqlParameterSourceProvider") ItemSqlParameterSourceProvider provider){
          super.setItemSqlParameterSourceProvider(provider);
      }
  
      @Autowired
      @Override
      public void setDataSource(@Qualifier("mysqlDataSource") DataSource dataSource){
          super.setDataSource(dataSource);
      }
  }
  </code></pre>
  
  <p>And here is my writer implementation : MySQLWriter.java</p>
  
  <pre><code>@Component
  public class EducationMysqlWriter extends AbstractJdbcBatchItemWriter&lt;Education&gt; {
      public EducationMysqlWriter(){
          super("");
          try {
              setSql("UPDATE ecole SET nom=:name WHERE id=:id");
          } catch (EmptyResultDataAccessException exception){
              setSql("INSERT INTO ecole (nom, id) VALUES (:name, :id");
          }
      }
  
  }
  </code></pre>
  
  <p>I need to update rows but if it fails (EmptyResultDataAccessException) I need to do an Insert.
  But EmptyResultDataAccessException is shown on log console and kills the job but the exception catching is never reachable into MySQLWriter.java ...</p>