I'm trying to add an aspect that is only applied on 'non- readonly transactions', so not for @Transactional(readonly=true)
This below code is applied for all methods that have an @Transactional annotation above it.
@AfterReturning("@annotation(org.springframework.transaction.annotation.Transactional)")
public void afterTransaction() {...}
There is an alternative by getting the information from the JoinPoint but it is cumbersome and I'd rather not go down that path.
The documentation seems not very specific about this.
You can use an execution
pointcut in order to limit annotation matching to joinpoints where the annotation has certain parameter values.
@AfterReturning("execution(@org.springframework.transaction.annotation.Transactional(readOnly=true) * *(..))")
public void process(JoinPoint joinPoint) {
System.out.println(joinPoint);
}
@AfterReturning("execution(@org.springframework.transaction.annotation.Transactional(readOnly=true) * *(..)) && @annotation(transactional)")
public void process(JoinPoint joinPoint, Transactional transactional) {
System.out.println(joinPoint + " -> " + transactional);
}