title: Spring @Transactional in an Aspect (AOP)
body: <p>I've created an Aspect which contains an @Transactional annotation. My advice is being invoked as expected, but the new entity AuditRecord is never saved to the database, it looks like my @Transactional annotation is not working.</p>
  
  <pre><code>@Aspect
  @Order(100)
  public class ServiceAuditTrail {
  
  private AppService appService; 
  private FooRecordRepository fooRecordRepository;
  
  @AfterReturning("execution(* *.app.services.*.*(..))")
  public void logAuditTrail(JoinPoint jp){
      Object[] signatureArgs = jp.getArgs();
      String methodName = jp.getSignature().getName();
  
      List&lt;String&gt; args = new ArrayList&lt;String&gt;();
      for(Object arg : signatureArgs){
          args.add(arg.toString());
      }
  
      createRecord(methodName, args);
  }
  
  @Transactional
  private void createRecord(String methodName, List&lt;String&gt; args){
      AuditRecord auditRecord = new AuditRecord();
      auditRecord.setDate(new Date());
      auditRecord.setAction(methodName);
      auditRecord.setDetails(StringUtils.join(args, ";"));
      auditRecord.setUser(appService.getUser());
      fooRecordRepository.addAuditRecord(auditRecord);
  }
  
      public void setAppService(AppService appService) {
          this.appService = appService;
      }
  
      public void setFooRecordRepository(FooRecordRepository fooRecordRepository) {
          this.fooRecordRepository= fooRecordRepository;
      }
  
  }
  </code></pre>
  
  <p>The bean context is as follows:</p>
  
  <pre><code>&lt;tx:annotation-driven transaction-manager="txManager.main" order="200"/&gt;
  
  &lt;aop:aspectj-autoproxy /&gt;
  
  &lt;bean id="app.aspect.auditTrail" class="kernel.audit.ServiceAuditTrail"&gt;
      &lt;property name="appService" ref="app.service.generic" /&gt;
      &lt;property name="fooRecordRepository" ref="domain.repository.auditRecord" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>My pointcut is intercepting only interfaces (service interfaces). The service methods may or may not be transactional. If the service method is transactional, I would like that transaction to be rolled back if the Advice fails for some reason.</p>
  
  <p>My question: Why is the transactional annotation being ignored? This is my first time building an AOP service with Spring, I would also welcome any architectural or implementation improvements.</p>
  
  <p>Thanks!</p>