Code Room
Code reviewHardcr-g318
Subject Missing rollbackLevel Senior–Staff~22 minCommon in Databases & SQL · Reliability & on-call interviewsIndustries Software development, Technology

Question

Review this Java booking method that charges the customer, then persists the reservation.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
@Transactionalpublic Booking book(BookingReq req) {    Charge c = paymentGateway.charge(req.getCardToken(), req.getAmount()); // external API    Booking b = new Booking(req, c.getId());    bookingRepo.save(b);   // may throw on constraint violation    inventory.decrement(req.getRoomId()); // local DB    return b;}
Run or narrate your approach, then ask the coach.