Announcement Announcement Module
Collapse
No announcement yet.
Strange Problem using hibernate interceptor/transaction advice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:47 AM. Reason: Added platform info
Working...
X