title: Spring declarative transaction using AOP with hibernate, still using the default transaction strategy
body: <p>I'm trying to implement a sample app using Spring transaction management using AOP and hibernate.
  Below is my config file</p>
  
  <pre><code>     &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:aop="http://www.springframework.org/schema/aop"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.2.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop-3.2.xsd "&gt;
  
  
      &lt;bean id="txManager"  
        class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt; 
        &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- Beans Declaration --&gt;
      &lt;bean id="userDAO" class="com.wjb.daoimpl.UserDAOImpl"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
           &lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;
              &lt;tx:attributes&gt;
             &lt;tx:method name="add*" read-only="true"/&gt;
             &lt;/tx:attributes&gt;
           &lt;/tx:advice&gt;
  
           &lt;aop:config&gt;
             &lt;aop:pointcut id="userOperation" expression="execution(* com.wjb.daoimpl.UserDAOImpl.*(..))"/&gt;
           &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="userOperation"/&gt;
           &lt;/aop:config&gt;
  
  
  &lt;!-- Database Configuration --&gt;
  &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
  &lt;property name="driverClassName" value="org.postgresql.Driver" /&gt;
  &lt;property name="url" value="jdbc:postgresql://10.12.30.180:4568/finitedb" /&gt;
  &lt;property name="username" value="finiteuser" /&gt;
  &lt;property name="password" value="finiteuser" /&gt;
  &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" 
       class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
  
      &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.wjb.user.model.User1&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  
      &lt;property name="dataSource"&gt;
        &lt;ref bean="dataSource"/&gt;
      &lt;/property&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;true&lt;/prop&gt;
         &lt;/props&gt;
      &lt;/property&gt;
   &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and this is my impl class</p>
  
  <pre><code>public class UserDAOImpl {
  
      Session session;
      SessionFactory sessionFactory;
  
      public void setSessionFactory(SessionFactory sessionFactory){
          this.sessionFactory = sessionFactory;
          session = this.sessionFactory.openSession();
      }
  
      public void addUser(User1 user) {
          session.save(user);
      }
  
      public SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
  }
  </code></pre>
  
  <p>When I run the application, I'm seeing the below lines in the log which shows that my spring transaction is not being invoked.</p>
  
  <blockquote>
    <p>Feb 27, 2013 11:00:20 AM org.hibernate.dialect.Dialect  INFO:
    HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect Feb
    27, 2013 11:00:20 AM
    org.hibernate.engine.jdbc.internal.LobCreatorBuilder
    useContextualLobCreation INFO: HHH000423: Disabling contextual LOB
    creation as JDBC driver reported JDBC version [3] less than 4 Feb 27,
    2013 11:00:20 AM
    org.hibernate.engine.transaction.internal.TransactionFactoryInitiator
    initiateService INFO: HHH000399: Using default transaction strategy
    (direct JDBC transactions) Feb 27, 2013 11:00:20 AM
    org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory  INFO:
    HHH000397: Using ASTQueryTranslatorFactory</p>
  </blockquote>
  
  <p>Am I missing anything? Please help</p>