Precise transaction control in an e-commerce application relies on @Transactional to guarantee that multi-step operations, like placing an order and charging payment, either fully succeed or fully roll back.
If payment processing fails after inventory has already been decremented within the same @Transactional method, Spring rolls back the inventory change automatically, preventing a customer from being charged without ever reducing stock levels, or vice versa.
@Transactional(rollbackFor = PaymentException.class)
public Order placeOrder(OrderRequest request) {
inventoryService.reserve(request.getItems());
Order order = orderRepository.save(new Order(request));
paymentService.charge(request.getPaymentInfo());
return order;
}A concise interview answer is
I'd wrap the order-placement logic in @Transactional so inventory update, order creation, and payment recording either all commit or all roll back together. For workflows that span separate microservices, I'd move to a saga pattern with compensating transactions, since a single ACID transaction can't span multiple databases.
Last updated: 16 July 2026
Previous question: Can transaction management be externally managed in Spring Boot, or must it be within the application?
Next question: How do you handle form validation in Spring Boot applications?