Results 1 to 1 of 1

Thread: Strange Problem using hibernate interceptor/transaction advice

  1. #1
    Join Date
    Mar 2007
    Posts
    4

    Default Strange Problem using hibernate interceptor/transaction advice

    Hi there,

    My platform is Tomcat 5.5.20, Spring 2.0.2, Java 5, Hibernate 3.2.1.ga
    I am having a problem with the following advice:

    Code:
       <bean id="daoAdvice"  class="org.springframework.orm.hibernate3.HibernateInterceptor">
       	<property name="sessionFactory" ref="sessionFactory"/>
       </bean>
    
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
          <tx:method name="make*" propagation="REQUIRED"/>
          <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
        </tx:attributes>
      </tx:advice>
    
    	<aop:config>	
    	  <aop:pointcut id="daoMethod"
    	        expression="execution(* com.virginmobile.cap.dataaccess.*.*(..))"/>	
    
    	  <aop:advisor 
    	      pointcut-ref="daoMethod"
    	      advice-ref="daoAdvice"/>	      
    
          <aop:advisor pointcut-ref="daoMethod" advice-ref="txAdvice"/>
    	</aop:config>
    I am using the generic dao patter so my interface is:
    package com.virginmobile.cap.dataaccess;

    Code:
    import java.util.List;
    public interface GenericDao<T, ID> {
    
        T findById(ID id, boolean lock);
    
    
        List<T> findAll();
    
    
        List<T> findByExample(T exampleInstance, String[] excludeProperty);
    
    
        T makePersistent(T entity);
    
    
        void makeTransient(T entity);
    }
    This is implemented in a GenericHibernateDao<T, ID> class. This is then implemented by the specific class in this case:


    When i invoke findByExample the advice is being weaved in. When I invoke findById, the advice isn't.

    ie.

    Code:
           List<CreditApplicationWrapper> applicationList = applicationWrapperDao.findByExample(wrapperTemplate, null);
            CreditApplicationWrapper application = applicationWrapperDao.findById(wrapperTemplate.getId(), false);
    The first line succeeds, the second line doesn't as the advice hasnt been weaved in and hence my hibernate session hasnt been created by the time the method is properly invoked.

    Thanks in advance,
    Andres
    Last edited by sloops77; Mar 15th, 2007 at 03:47 AM. Reason: Added platform info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •