@Transactional(rollbackFor = MyCheckedException.class)
public void foo() {
throw new RuntimeException();
}
Will this transaction get rolled back, or do I need to include RuntimeException.class in the annotation as well?
@Transactional(rollbackFor = MyCheckedException.class)
public void foo() {
throw new RuntimeException();
}
Will this transaction get rolled back, or do I need to include RuntimeException.class in the annotation as well?
No need to include
RuntimeException
inrollbackFor
list. It will handle that even if you do not mention it.I've tried it out for jdbcTemplate:-
Source
So it can roll back with CheckedException as well (RuntimeException by default), example: