title: @transactional not working spring 4 hibernate 4
body: <p>I want to use transactionManager of spring.
  My spring configuration is here:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xmlns="http://www.springframework.org/schema/beans" 
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-4.0.xsd
          "&gt;
  
  
  &lt;bean id="dataSource" 
          class="org.apache.commons.dbcp.BasicDataSource" 
          depends-on="propertyPlaceholderConfigurer"
          p:driverClassName="org.postgresql.Driver"
          p:url="${db.url}" 
          p:username="${db.username}" 
          p:password="${db.password}"
          destroy-method="close" /&gt;
  
  
  
  
  &lt;context:spring-configured /&gt;
  &lt;context:annotation-config /&gt;
  
  &lt;bean id="sessionFactory" 
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" 
          depends-on="flywayAutomaticMigrationBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan" value="com.example" /&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;false&lt;/prop&gt;
              &lt;prop key="hibernate.default_schema"&gt;restProj&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;com/example/db/hbm/user/AuthUser.hbm.xml&lt;/value&gt;
              &lt;value&gt;com/example/db/hbm/user/User.hbm.xml&lt;/value&gt;
              &lt;value&gt;com/example/db/hbm/user/Role.hbm.xml&lt;/value&gt;
              &lt;value&gt;com/example/db/hbm/user/Feature.hbm.xml&lt;/value&gt;
  
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt; 
  
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  &lt;context:component-scan base-package="com.example.model" &gt;
      &lt;context:include-filter type="regex" expression=".*\.dao\..*DAO"/&gt;
      &lt;context:include-filter type="regex" expression=".*\.logic\..*Mgr"/&gt;
  &lt;/context:component-scan&gt;
  &lt;context:component-scan base-package="com.example.commons" &gt;
      &lt;context:include-filter type="regex" expression=".*\.dao\..*DAO"/&gt;
      &lt;context:include-filter type="regex" expression=".*\.logic\..*Mgr"/&gt;
  &lt;/context:component-scan&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>And this is one of my Manager class:</p>
  
  <pre><code>import org.springframework.transaction.annotation.Transactional;
  
  public class UserMgr extends BaseUserMgr {
  
      @Transactional (rollbackFor = Exception.class)
      public void checkTransaction(){
          Feature feature = new Feature();
          feature.setExtuid(UUID.randomUUID().toString());
          feature.setName("boogh");
          feature.setDescription("salam");
          FeatureDAO.getInstance().save(feature);
      }   
  }
  </code></pre>
  
  <p>When I run  UserMgr.checkTransaction() Data doesn't save.
  Can anyone explane to me what is wrong?</p>
  
  <p><strong>__UPDATE___</strong></p>
  
  <p>This is my FeatureDao Save Method :</p>
  
  <pre><code>      public java.lang.Long save(com.example.model.user.Feature feature)
          throws org.hibernate.HibernateException {
          return (java.lang.Long) super.save(feature);
      }
  </code></pre>
  
  <p>and this is superclass Save method:</p>
  
  <pre><code>protected Serializable save(final Object obj) {
      return save(obj, getSession());
  }
  </code></pre>
  
  <p>and the getSession() method get session from spring sessionFactory.</p>
  
  <p>And this is my FeatureDao getInstance() method:</p>
  
  <pre><code>public static com.model.user.dao.FeatureDAO getInstance() {
      return com.example.core.spring.ApplicationContextUtil.getApplicationContext().getBean(com.example.model.user.dao.FeatureDAO.class);
  }
  </code></pre>