Question d’entretien chez IBM

Counter value incremented inside transaction. If transaction fails, class value updated? @Service public class PaymentService { private int counter = 0; @Transactional public void processPayment() { counter++; paymentRepository.save(payment); throw new RuntimeException("Failed"); } }

Réponse à la question d'entretien

Utilisateur anonyme

6 juin 2026

Database changes rollback; counter remains changed. Initial counter = 0 After execution = 1