title: Mybatis sqlsession unable to rollback
body: <p>I'm working in <code>Spring</code> project, using <code>mybatis 3</code> and <code>oracle 11g</code>.</p>
  
  <p>I tried to <code>rollback transactions</code> when errors happen. However, rollback seems not to be working. </p>
  
  <p>Source code bellow:</p>
  
  <p><strong>ApplicationContext.xml</strong></p>
  
  <pre><code>    &lt;tx:annotation-driven transaction-manager="transactionManager"/&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><strong>Service</strong></p>
  
  <pre><code>int changeLimitSrcAcc(String src_acctno,String dest_acctno, String amt);
  </code></pre>
  
  <p><strong>ServiceImpl</strong></p>
  
  <pre><code>    @Override
      public int changeLimitSrcAcc(String src_acctno, String dest_acctno,
              String amt) {
          int result = 0;
          SqlSessionFactory sqlMapper = MyBatisService.getSessionFactory();
          SqlSession sqlSession = sqlMapper.openSession();
          CustomerAccountMapper mapper = sqlSession
                  .getMapper(CustomerAccountMapper.class);
  
          try {
              int result1 = mapper.changeLimitSrcAcc(src_acctno, amt);
              int result2 = mapper.changeLimitDescAcc(dest_acctno, amt);
              if (result1 != 1 || result2 != 1)
                  throw new Exception("Error happened");
              else result = 1;
              sqlSession.commit();
          } catch (Exception e) {
              System.out.println(e.getMessage());
              sqlSession.rollback();
          } finally {
              sqlSession.close();
          }
          return result;
      }
  </code></pre>
  
  <p>I also tried to <code>rollback</code> a single <code>transaction</code> but it still committed.</p>
  
  <p>I read on Mybatis home page and it said <code>@transaction</code> annotations doesn't need. I also put the <code>annotations</code> and nothing happened.</p>
  
  <p>Any solutions?</p>
  
  <p>Thanks.</p>