Sto cercando di utilizzare HibernateInterceptor come consiglio e sto cercando di autorizzarlo.Autowiring HibernateInterceptor as Advice
Il codice è il seguente,
@Aspect
public class InterceptorAdvice{
private HibernateInterceptor hibernateInterceptor;
@Autowired
public void setHibernateInterceptor(@Qualifier("hibernateInterceptor") HibernateInterceptor hibernateInterceptor) {
this.hibernateInterceptor = hibernateInterceptor;
}
@Around("execution(* *..*.dao..*.*(..))")
public Object interceptCall(ProceedingJoinPoint joinPoint) throws Exception {
Object obj = null;
try{
.......
}catch(Exception e){
e.printStackTrace();
}
return obj;
}
}
Di seguito è riportato il mio mapping XML,
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor" autowire="byName">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--To enable AspectJ AOP-->
<aop:aspectj-autoproxy/>
<!--Your advice-->
<bean class="com.web.aop.InterceptorAdvice"/>
<!--Looks for any annotated Spring bean in com.app.dao package-->
<context:component-scan base-package="com.web.dao"/>
<!--Enables @Autowired annotation-->
<context:annotation-config/>
Quando controllo il hibernateInterceptop, tutto quello che ottiene è NULL: (... Non so perché il suo grado di autowire l'intercettore ibernazione
Tutte le idee? Grazie per il vostro tempo.
Cheers, J
Cosa succede quando si imposta manualmente un'altra proprietà per 'HibernateInterceptor' nella finestra di configurazione di Spring? –