Pregunta de entrevista de 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"); } }

Respuesta de la entrevista

Anónimo

6 jun 2026

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