@Test public void checked_exception_will_commit_transaction() throws Exception { final Performer delegate = newMock(Performer.class); final EntityManagerManager manager = newMock(EntityManagerManager.class); final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class); final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager); final EntityManager entityManager = newMock(EntityManager.class); final EntityTransaction transaction = newMock(EntityTransaction.class); final SQLException se = new SQLException("Checked."); final AspectInterceptorBuilder<Performer> builder = aspectDecorator.createBuilder( Performer.class, delegate, "foo.Bar"); advisor.addTransactionCommitAdvice(builder); final Performer interceptor = builder.build(); train_getActiveTransaction(manager, entityManager, transaction); delegate.perform(); setThrowable(se); train_commitActiveTransaction(transaction); replay(); try { interceptor.perform(); unreachable(); } catch (final SQLException ex) { Assert.assertSame(ex, se); } verify(); }
@Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } }
JpaTransactionAdvisorImpl implements JpaTransactionAdvisor { @Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } } }
JpaTransactionAdvisorImpl implements JpaTransactionAdvisor { @Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } } JpaTransactionAdvisorImpl(EntityManagerManager manager,
            EntityTransactionManager transactionManager); }
JpaTransactionAdvisorImpl implements JpaTransactionAdvisor { @Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } } JpaTransactionAdvisorImpl(EntityManagerManager manager,
            EntityTransactionManager transactionManager); @Override void addTransactionCommitAdvice(MethodAdviceReceiver receiver); }
JpaTransactionAdvisorImpl implements JpaTransactionAdvisor { @Override public void addTransactionCommitAdvice(MethodAdviceReceiver receiver) { for (final Method m : receiver.getInterface().getMethods()) { if (m.getAnnotation(CommitAfter.class) != null) { PersistenceContext annotation = receiver.getMethodAnnotation(m, PersistenceContext.class); receiver.adviseMethod(m, methodAdvices.get(annotation == null ? null : annotation.unitName())); } } } JpaTransactionAdvisorImpl(EntityManagerManager manager,
            EntityTransactionManager transactionManager); @Override void addTransactionCommitAdvice(MethodAdviceReceiver receiver);  }