Transactions, Spring.
userRepository; @Transactional public User getUser(String id){ User user = userRepository.get(id); user.setMobile("12345678"); //Checked Exception if(user.age < 18) throw UserNotEligibleToDriveException(); //below line not executed userRepository.save(user)} } The above code will be rolled back