@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
log.debug("[JpaLocalTransactionInterceptor]进入=》"+methodInvocation.getMethod().getName());
EntityManagerFactoryHolder emfH = GuiceContext.getInstance().getBean(EntityManagerFactoryHolder.class);
EntityManagerInfo entityManager = emfH.getEntityManagerInfo();
Method method = methodInvocation.getMethod();
Transactional transactional = method.getAnnotation(Transactional.class);
if(transactional == null){
transactional = method.getDeclaringClass().getAnnotation(Transactional.class);
}
TransactionalType type = transactional.type();
if(type != TransactionalType.READOLNY){
entityManager.setNeed2ProcessTransaction(true);
}
final EntityTransaction transaction = entityManager.getEntityManager().getTransaction();
if(transaction.isActive()){
return methodInvocation.proceed();
}