title: @Transaction annotation is not woring with spring jdbctemplate
body: <p>I am using spring 3.0.5 version. I am doing just simple test program to test the behavior of transaction but not getting. I have programmed three layer architecture project. In which dao layer contain following line of code.</p>
  
  <pre><code>@Repository("commonDao")
  @Transactional
  public class CommonDaoImpl implements CommonDao {
      private static Logger logger = Logger.getLogger(CommonDaoImpl.class);
      @Autowired
      private DataSource dataSource;
      private JdbcTemplate jdbcTemplate;
  @Autowired
      public void setSessionFactory(){
          jdbcTemplate = new JdbcTemplate(dataSource);
      }
      @Override
      public Object makePayment(Object e) {
              String sql = "insert into payment (id, name, amount) values('abc', 100)";
                  return new NullPointerException();
      }
  @Override
      public Object signUp(Object e) {
              String sql = "insert into login (userid, password) values('naveen', 'password')";
              return jdbcTemplate.update(sql);
      }
  }
  </code></pre>
  
  <p>Service Layer looks like this. </p>
  
  <pre><code>@Service
  public class CommonServiceImpl implements CommonService {   
  
      private static Logger logger = Logger.getLogger(CommonServiceImpl.class);
  
      @Autowired
      private CommonDao commonDao;
  
  //  I tried both of them one by one but not worked
      @Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
      @Override
      public boolean makePayment(HttpServletRequest request) {
          WebApplicationContext ctxt = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
          commonDao.signUp(new Object());
          commonDao.makePayment(new Object());    
          return true;
      }
  
  }
  </code></pre>
  
  <p>controller looks like this</p>
  
  <pre><code>@RequestMapping("/doPayment")
      public void doPayment(HttpServletRequest request){
          logger.info("controller");
          WebApplicationContext ctxt = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
          commonService.makePayment(request);
      }
  </code></pre>
  
  <p>dispatcher-servlet.xml file </p>
  
  <pre><code>      &lt;context:component-scan base-package="com" /&gt;
          &lt;!--    &lt;context:annotation-config /&gt; --&gt;
      &lt;bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/test" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="password" /&gt;
      &lt;/bean&gt;
  &lt;!-- Add this tag to enable annotations transactions --&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>web.xml file contains </p>
  
  <pre><code>  &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
                 org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;context-param&gt;   
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener
          &lt;/listener-class&gt;
    &lt;/listener&gt;
  </code></pre>
  
  <p>its very simple program. In which service layer called two methods of dao signup and makePayment under transaction. Signup method executing successfully but makePayment throw an exception. Now the problem is because both method executing under transaction so there will be not operation happen against database. But in login table data is inserted whereas payment table is empty. But as per my understanding towards transaction none of entry should be inserted into a database. Can some one help me what's going. </p>
  
  <pre><code>Invoking request handler method: public void com.controller.CommonController.doPayment(javax.servlet.http.HttpServletRequest)
  controller
  Using transaction object [org.springframework.jdbc.datasource.DataSourceTransactionManager$DataSourceTransactionObject@1b7379b]
  Creating new transaction with name [com.service.CommonService.makePayment]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT,-throwable
  Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/test]
  Acquired Connection [com.mysql.jdbc.JDBC4Connection@74b8d3] for JDBC transaction
  Switching JDBC Connection [com.mysql.jdbc.JDBC4Connection@74b8d3] to manual commit
  Bound value [org.springframework.jdbc.datasource.ConnectionHolder@6a56c0] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@25a0f5] to thread [http-bio-8080-exec-14]
  Initializing transaction synchronization
  Getting transaction for [com.service.CommonService.makePayment]
  Executing SQL update [insert into login (userid, password) values('naveen', 'password')]
  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6a56c0] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@25a0f5] bound to thread [http-bio-8080-exec-14]
  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6a56c0] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@25a0f5] bound to thread [http-bio-8080-exec-14]
  SQL update affected 1 rows
  Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@6a56c0] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@25a0f5] bound to thread [http-bio-8080-exec-14]
  Completing transaction for [com.service.CommonService.makePayment]
  Triggering beforeCommit synchronization
  Triggering beforeCompletion synchronization
  Initiating transaction commit
  Committing JDBC transaction on Connection [com.mysql.jdbc.JDBC4Connection@74b8d3]
  Triggering afterCommit synchronization
  Triggering afterCompletion synchronization
  Clearing transaction synchronization
  Removed value [org.springframework.jdbc.datasource.ConnectionHolder@6a56c0] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@25a0f5] from thread [http-bio-8080-exec-14]
  Releasing JDBC Connection [com.mysql.jdbc.JDBC4Connection@74b8d3] after transaction
  Returning JDBC Connection to DataSource
  Invoking afterPropertiesSet() on bean with name 'action/doPayment'
  Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
  Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
  Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'action/doPayment'; URL [/WEB-INF/pages/action/doPayment.jsp]] in DispatcherServlet with name 'dispatcher'
  Forwarding to resource [/WEB-INF/pages/action/doPayment.jsp] in InternalResourceView 'action/doPayment'
  Successfully completed request
  </code></pre>
  
  <p>when i saw the log file it is using the transaction instance. can some help to come out this problem.</p>