title: spring transaction not working?
body: <p>Hi i am try to develop spring and hibernate app with transactions , i am using spring 4.x and hibernate 4.x , here is my code snippet</p>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;tx:annotation-driven /&gt;
       &lt;context:annotation-config /&gt;
  
       &lt;context:component-scan base-package="com.xyx.service" /&gt;
       &lt;context:component-scan base-package="com.xyz.dao" /&gt;
  
  
      &lt;import resource="conf/spring/persistence.xml" /&gt;
  </code></pre>
  
  <p><strong>servlet-context.xml</strong></p>
  
  <pre><code>&lt;context:component-scan base-package="com.xyx.webservice.components" /&gt;
       &lt;mvc:annotation-driven /&gt;
   &lt;bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
      &lt;/bean&gt;  
  
      &lt;!--      Configure to plugin JSON as request and response in method handler --&gt;
    &lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt;
          &lt;property name="messageConverters"&gt;
              &lt;list&gt;
                  &lt;ref bean="jsonMessageConverter"/&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt; 
  </code></pre>
  
  <p><strong>persistance.xml</strong></p>
  
  <pre><code>&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/xyx" /&gt;
              &lt;property name="username" value="root" /&gt;
              &lt;property name="password" value="root" /&gt;
        &lt;/bean&gt;
  
      &lt;bean id="sessionFactory"           class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource"/&gt;
          &lt;/property&gt;
          &lt;property name="packagesToScan" value="com.xyz.model" /&gt;       
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
  
                    &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
                    &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;           
                    &lt;prop key="hibernate.cache.use_second_level_cache"&gt;false&lt;/prop&gt;    
              &lt;/props&gt;
          &lt;/property&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id = "transactionManager" class = "org.springframework.orm.hibernate4.HibernateTransactionManager"   p:sessionFactory-ref= "sessionFactory" &gt; 
     &lt;/bean&gt;
  
  
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>and finnaly meservice look like this </p>
  
  <pre><code>@Transactional(propagation=Propagation.REQUIRED,rollbackFor=RuntimeException.class)
      public Object loadCategories(UserContactsInputVO inputVo) {
  
          User user= getUserObject(inputVo);
  
  
          userDAO.saveOrUpdateForTrancasction(user);
          System.out.println(user.getUserId());
  
          //getAudioFilesBasedOnCategories();
          try{
              return getAudioFilesBasedOnCategories();
          }catch (RuntimeException e) {
              e.printStackTrace();
          }
          return new CategoryResponseVo();
      }
  </code></pre>
  
  <p>and  </p>
  
  <pre><code>@Transactional(propagation=Propagation.REQUIRED)
      public CategoryResponseVo  getAudioFilesBasedOnCategories()
      {
  
          try{
              if(true)
          throw new RuntimeException();
  
          }finally{
  
          }
          return vo;
  
      }
  </code></pre>
  
  <p>here runtime exception occurs but db records are not rolled backed.</p>