title: Spring Hibernate + AOP
body: <p>Help! I'm using Spring+Hibernate and I'm trying to use AOP like this :</p>
  
  <pre><code>package ua.i.pustovalov.table;
  enter code here
  
  @Aspect
  public class Aoprad {
  
      @Pointcut("execution(* *getAll(..))")
      public void performance() {
      }
  
      public Aoprad() {
  
      }
  
      @Around("performance()")
      public void AfterAndPriv(ProceedingJoinPoint joinPoint) {
      try {
  
          System.out.println("Open query");
          joinPoint.proceed();
          System.out.println("Close query");
      } catch (Throwable e) {
          e.printStackTrace();
      }
  
      }
  
  }
  </code></pre>
  
  <p>When I try to use my method, it returns null.</p>
  
  <pre><code>public class TestDao {
  
  public static void main(String[] args) {
  ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
      new String[] { "applicationContext.xml" }, true);
  
  DaoInterface das = (DaoInterface) context.getBean("dataDao");
  
  System.out.println(das.getAll());
  
  }
  
  &lt;context:annotation-config /&gt;
  
  &lt;aop:aspectj-autoproxy /&gt;
  &lt;context:component-scan base-package="ua.i.pustovalov.*"&gt;
  &lt;/context:component-scan&gt;
  
  
  
  
  
  &lt;bean id="audience" class="ua.i.pustovalov.table.Aoprad" /&gt;
  
  
  &lt;aop:config&gt;
      &lt;aop:pointcut id="myPointcut"
          expression="execution(* ua.i.pustovalov.maven.*.*(..))" /&gt;
      &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut" /&gt;
  &lt;/aop:config&gt;
  
  
  
  &lt;tx:advice id="txAdvice" transaction-manager="transactionManager"&gt;
      &lt;tx:attributes&gt;
          &lt;!-- &lt;tx:method name="get*" propagation="REQUIRED" read-only="true" /&gt; --&gt;
          &lt;tx:method name="getAll*" propagation="REQUIRED" read-only="true" /&gt;
  
      &lt;/tx:attributes&gt;
  &lt;/tx:advice&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName"&gt;
          &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="url"&gt;
          &lt;value&gt;jdbc:mysql://localhost:3306/homebase&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="username"&gt;
          &lt;value&gt;root&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="password"&gt;
          &lt;value&gt;&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="configLocation" value="classpath:/hibernate.cfg.xml" /&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.current_session_context_class"&gt;thread&lt;/prop&gt;
              &lt;!-- &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt; --&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataDao" class="ua.i.putsovalov.dao.DaoStudent"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>My DAO class</strong></p>
  
  <pre><code>package ua.i.putsovalov.dao;
  
  public class DaoStudent extends HibernateDaoSupport implements DaoInterface {
  
  public DaoStudent() {
  }
  
  @Override
  protected HibernateTemplate createHibernateTemplate(
      SessionFactory sessionFactory) {
  HibernateTemplate result = super
      .createHibernateTemplate(sessionFactory);
  result.setAllowCreate(true);
  return result;
  }
  
  @Override
  public Student get(int id) {
  
  return (Student) getSession().get(Student.class, id);
  }
  
  @Override
  public Student get(String text) {
  return (Student) getSession().get(Student.class, text);
  }
  
  @SuppressWarnings("unchecked")
  @Override
  public Collection&lt;Student&gt; getAll() {
  return getSession().createCriteria(Student.class).list();
  }
  
  }
  </code></pre>
  
  <p><strong>And interface</strong></p>
  
  <pre><code>public interface DaoInterface {
  
  Student get(int id);
  
  Student get(String text);
  
  Collection&lt;Student&gt; getAll();
  }
  </code></pre>
  
  <p>What steps can I take to debug this issue?</p>