title: Spring Transaction propagation REQUIRED, REQUIRES_NEW
body: <p>in following code method <code>doService1()</code> update correct sql but <code>doService2()</code> sql has some issue , but when i call <code>doService()</code> it has to commit the <code>doService1()</code> update to DB even though the <code>doService2()</code> has a <code>sql exception</code> because <code>doService2()</code>  has a <code>REQUIRES_NEW Propagation</code> type but when i nun this <code>doService1()</code> update does not commit DB..</p>
  
  <pre><code>@Service public class DbClass {
  
        static Logger log = Logger.getLogger(
                DbClass.class.getName());
  
  @Autowired
  private DataSource dataSource;
  
  @Transactional(propagation=Propagation.REQUIRED)
  public void doService(){
      doService1();
      doService2();
  }
  
  @Transactional(propagation=Propagation.REQUIRED)
  public void doService1(){
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
      String sql = "  update BATCHJOBSTATUS set PROCESSINGDATE = '20130322'  " ;
      int rowCount1 =  jdbcTemplate.update(sql);
      System.out.println(" rowCount1 &gt;" + rowCount1);
  }
  
  @Transactional(propagation=Propagation.REQUIRES_NEW)
  public void doService2(){
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
      String sql = "  update aa set a_name = 'hhh' where a_id = 4 and " ;
      int rowCount1 =  jdbcTemplate.update(sql);
      System.out.println(" rowCount2 &gt;" + rowCount1);
  }   
  }
  </code></pre>
  
  <hr>
  
  <p>as your guys suggestion test in following way as well but still facing the same problem.
  here i <code>doService2()</code> in a separate class but even though still have the same problem as above</p>
  
  <pre><code>@Service
  public class DbClass {
  
    static Logger log = Logger.getLogger(
            DbClass.class.getName());
  
  @Autowired
  private DataSource dataSource;
  
  @Autowired
  private DbClass2 dbClass2;
  
  @Transactional
  public void doService(){
      doService1();
      dbClass2.doService2();
  }
  
  @Transactional(propagation=Propagation.REQUIRED )
  public void doService1(){
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
      String sql = "  update BATCHJOBSTATUS set PROCESSINGDATE = '20130322'  " ;
      int rowCount1 =  jdbcTemplate.update(sql);
      System.out.println(" rowCount1 &gt;" + rowCount1);
  
      }
  
  
  }
  
  
  @Service
  public class DbClass2 {
  
  
  @Autowired
  private DataSource dataSource;
  
  @Transactional(propagation=Propagation.REQUIRES_NEW)
  public void doService2() {
      System.out.println("*******doService2*********`");
  
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
  
      String sql = "  update aa set a_name = 'hhh' where a_id_ = 4  " ;
  
      int rowCount2 =  jdbcTemplate.update(sql);
  
      System.out.println(" rowCount2 &gt;" + rowCount2);
  
  }
  
  }
  
  
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:oxm="http://www.springframework.org/schema/oxm"
           xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
  
      xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/tx 
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"&gt;
  
  
      &lt;context:annotation-config /&gt;
  
      &lt;context:component-scan base-package="com.spring"/&gt;
  
        &lt;tx:annotation-driven transaction-manager="txManager1" proxy-target-class="true"/&gt;
  
  
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
          &lt;property name="url" value="jdbc:oracle:thin:@192.168.8.121:1521:h3" /&gt;
          &lt;property name="username" value="admin" /&gt;
          &lt;property name="password" value="admin" /&gt;
      &lt;/bean&gt;
  
  
    &lt;bean id="txManager1" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" &gt;
    &lt;property name="dataSource" ref="dataSource"/&gt;
    &lt;/bean&gt;
  
      &lt;bean id="batchJob" class="com.spring.jdbc.BatchJob"&gt;
      &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>