title: spring mybatis transaction getting committed
body: <p>I am trying to use mybatis spring transaction management
  My problem is that the transactions are getting committed even if an exception is thrown.
  Relatively new to this, anykind of help is much appreciated.
  Following are the code snippets</p>
  
  <p>spring xml configuration</p>
  
  <pre><code> &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
  
          &lt;property name="location"&gt;
  
              &lt;value&gt;classpath:Config.properties&lt;/value&gt;
  
          &lt;/property&gt;
  
      &lt;/bean&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
       &lt;property name="driverClassName" value="${db.driver}"/&gt;
      &lt;property name="url" value="${db.url}"/&gt;
      &lt;property name="username" value="${db.user}"/&gt;
      &lt;property name="password" value="${db.pass}"/&gt;
      &lt;property name="defaultAutoCommit" value="false" /&gt;
      &lt;/bean&gt;
  
  
  
       &lt;bean id="transactionManager"      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;/bean&gt;
  
  
    &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  
  &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
          &lt;property name="configLocation" value="classpath:Configuration.xml" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.mybatis.spring.SqlSessionTemplate" id="sqlSessionTemplate"&gt;
          &lt;constructor-arg ref="sqlSessionFactory"/&gt;
     &lt;/bean&gt;
  </code></pre>
  
  <p>Service class</p>
  
  <pre><code>@Transactional(rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
  public void insertNotes(String noteTypeId,String confidentialValue,String summaryValue,String notes ,String notesId,String noteTypeValue,
          String claimNumber,String notepadId,String mode)
  {
  
  
          NotepadExample notepadExample= new NotepadExample();
  
          //to be moved into dao class marked with transaction boundaries
          Notepad notepad = new Notepad();
          notepad.setAddDate(new Date());
          notepad.setAddUser("DummyUser");
          if("true".equalsIgnoreCase(confidentialValue))
              confidentialValue="Y";
          else
              confidentialValue="N";
          notepad.setConfidentiality(confidentialValue);
          Long coverageId=getCoverageId(claimNumber);
          notepad.setCoverageId(coverageId);
          notepad.setDescription(summaryValue);
  
          notepad.setEditUser("DmyEditUsr");
          //notepad.setNotepadId(new Long(4)); //auto sequencing
          System.out.println(notes);
          notepad.setNotes(notes);
          notepad.setNoteType(noteTypeValue); //Do we really need this?
          notepad.setNoteTypeId(Long.parseLong(notesId));
          if("update".equalsIgnoreCase(mode))
          {
              notepad.setNotepadId(new Long(notepadId));
              notepad.setEditDate(new Date());
              notepadMapper.updateByPrimaryKeyWithBLOBs(notepad);
  
          }
          else
              notepadMapper.insertSelective(notepad);
  
                throw new java.lang.UnsupportedOperationException();
  
  
  
  
  
  }
  </code></pre>
  
  <p>Not sure where I am going wrong...</p>
  
  <p>The current call is from the controller as given below</p>
  
  <pre><code> @Controller
  public class NotesController {
  
      private static final Logger logger = LoggerFactory
              .getLogger(NotesController.class);
  
      @Autowired
      private Utils utility;
  
      @Autowired
       NotepadService notepadService;
  
  
      public  @ResponseBody List&lt;? extends Object&gt; insertNotes(HttpServletRequest request,
          HttpServletResponse response,@RequestParam("noteTypeValue") String noteTypeId,
      @RequestParam("confidentialValue")String confidentialValue,
      @RequestParam("summaryValue")String summaryValue,
      @RequestParam("notes")String notes ,
      @RequestParam("notesId")String notesId,
      @RequestParam("noteTypeValue")String noteTypeValue,
      @RequestParam("claimNumber")String claimNumber,
      @RequestParam("notepadId")String notepadId,
      @RequestParam("mode")String mode) {
  
          try {
              notepadService.insertNotes(noteTypeId, confidentialValue, summaryValue, notes, notesId, noteTypeValue, claimNumber, notepadId, mode);
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return null;  
      }
  }
  </code></pre>