Advertisement
Nicksed

Untitled

Jun 7th, 2023
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. // what will return getUserCount() if called after processTransaction()
  2.  
  3. @Service
  4. public class TransactionalPuzzlerService {
  5.  
  6.     @Autowired
  7.     private UserRepository userRepository;
  8.  
  9.     @Transactional
  10.     public void performTransactionalOperation() {
  11.         userRepository.deleteAll();
  12.         throw new RuntimeException("Oops! Something went wrong.");
  13.     }
  14.  
  15.     public void processTransaction() {
  16.         performTransactionalOperation();
  17.     }
  18.  
  19.     public int getUserCount() {
  20.         return userRepository.count();
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement