#170 Code Review of an Order Service
Will everything work? If so, how many transactions will be opened? If not, what must be changed to make it work?
@Service
@RequiredArgsConstructor
@Transactional
public class OrderService {
private final BalanceService balanceService;
public void createOrder() {
// Various balance validation logic
paymentOrder();
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
private void paymentOrder() {
balanceService.chargeOff();
}
}
@Service
@Transactional
class BalanceService {
public void chargeOff() {
// Logic for debiting money from the account
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor