Hi,
I am fairly new to spring
My dao interface
I am having a exception translator to translate DataAccessException to my AppExceptionCode:@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) public interface VehicleDao { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = VehicleException.class, readOnly = false) public Vehicle addVehicle(String name, String subType, NumberOfPassengers num) throws VehicleException; //other methods }
But the rethrow method is not called.Code:@Aspect public class ExceptionTranslator implements AfterAdvice{ @AfterThrowing(throwing="e",pointcut="@annotation(org.springframework.transaction.annotation.Transactional)") public void rethrow( DataAccessException e ) throws VehicleException { System.out.println("DAE:"+e.getRootCause()); //my code throw new VehicleException(); }
If I use my @AfterThrowing like:
instead ofCode:@AfterThrowing(throwing="e",pointcut="execution(* *.add*(..))")
everythings working fine.Code:@AfterThrowing(throwing="e",pointcut="@annotation(org.springframework.transaction.annotation.Transactional)")
Can anyone please explain me the reason behind this behaviour and how to solve this?


Reply With Quote