Spring transactional dont rollback when exception is mapped by
ExceptionMapper
I have a RestFull service (implemented by jersey) . The service is marked
with @Transactional.
I declared an ExceptionMapper like this:
@Provider public class ThrowableMapper implements ExceptionMapper {
private static final Logger log = Logger.getLogger(ThrowableMapper.class);
public Response toResponse(Throwable ex) {
log.error("throwable", ex);
return Response.status(500).entity("Internal
Error").type("text/plain").build();
}
}
when exceptionmapper is not declared than transaction is rollback.
However, when i have an ExceptionMapper transaction is commit without
rollback.
I assume that since exception is caught by ExceptionMapper than spring
transaction proxy dosnt detect that exception was thrown ,so transaction
is not rollback.
Is there a way to overcome this?
No comments:
Post a Comment