在DAO中围绕建议执行Spring AOP在服务中返回null
我已经围绕advice编写了切入点和定制,它将执行一个Dao方法 切入点在DAO中围绕建议执行Spring AOP在服务中返回null,spring,aop,Spring,Aop,我已经围绕advice编写了切入点和定制,它将执行一个Dao方法 切入点 @Pointcut("execution(* com.dao.*.get*(..))") public void creditPointcut(){ } 围绕建议 @Around("creditPointcut()") public void around(ProceedingJoinPoint point) throws Throwable{ LOGGER.info("Meth
@Pointcut("execution(* com.dao.*.get*(..))")
public void creditPointcut(){
}
围绕建议
@Around("creditPointcut()")
public void around(ProceedingJoinPoint point) throws Throwable{
LOGGER.info("Method name: "+point.getSignature().getName()+" started");
point.proceed();
LOGGER.info("Method name: "+point.getSignature().getName()+" ended");
}
目标Dao方法
public Account getAccountDetails(int accntNo) {
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("from Account where accountNo=:acctNo");
query.setInteger("acctNo", accntNo);
Account account = (Account)query.list().get(0);
return account;
}
但是,此建议在我的服务中返回空帐户
服务层方法
@Override
@Transactional(isolation=Isolation.READ_COMMITTED )
public Account getAccountDetails(int accntNo) {
Account account = accountDao.getAccountDetails(accntNo);
return account;
}
请帮助我,为什么在执行Dao中的around建议后,我在服务中得到空帐户。这是因为您没有从建议中返回任何内容:
@Around("creditPointcut()")
public Object around(ProceedingJoinPoint point) throws Throwable{
LOGGER.info("Method name: "+point.getSignature().getName()+" started");
Object ret = point.proceed();
LOGGER.info("Method name: "+point.getSignature().getName()+" ended");
return ret;
}