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:
I am using the generic dao patter so my interface is: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>
package com.virginmobile.cap.dataaccess;
This is implemented in a GenericHibernateDao<T, ID> class. This is then implemented by the specific class in this case: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); }
When i invoke findByExample the advice is being weaved in. When I invoke findById, the advice isn't.
ie.
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.Code:List<CreditApplicationWrapper> applicationList = applicationWrapperDao.findByExample(wrapperTemplate, null); CreditApplicationWrapper application = applicationWrapperDao.findById(wrapperTemplate.getId(), false);
Thanks in advance,
Andres


Reply With Quote