@Transactional(rollbackFor = MyCheckedException.class)
public void foo() {
throw new RuntimeException();
}
Will this transaction get rolled
So it can roll back with CheckedException as well (RuntimeException by default), example:
@Transactional(rollbackFor = Exception.class)
public void save(Book book) throws Exception {
bookRepository.save(book);
System.out.println("Saved in transcation.");
// No data is persisted
if (true) {
throw new Exception();
}
}