Simplified Transaction
Example Code https://github.com/jurogrammer/dtrans Situation When you want to separate transactions for different operations, but creating a new service class for this feels cumbersome. Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 @Service @RequiredArgsConstructor public class SaveServiceVer1 { private final UserRepository userRepository; private final OrderRepository orderRepository; @Transactional public void save() { userRepository.save(new User("홍길동")); // If an error occurs while saving the order, you still want the user to be saved as is. saveOrder(); } public void saveOrder() { orderRepository.save(new Order()); throw new RuntimeException("Error occurred while saving order"); } } Idea Even if an error occurs in saveOrder and the order is rolled back, the User save should still be performed. ...