#179 Code Review of a Service with Transactional Calls

Companies:
Digitalleague
Themes:
SpringTransactionsCode Review

Explain what happens when review() is called:

@Service
@RequiredArgsConstructor
public class Review {
    private final AImpl a;

    public void review() {
        a.run();

        AImpl a1 = new AImpl();
        a1.run();
    }
}

interface A {
    void run();
}

@Service
public static class AImpl implements A {

    @Override
    @Transactional
    public void run() {
        // Database query
        calculate();
    }

    @Transactional(propagation = Propagation.MANDATORY)
    public void calculate() {
        // Database query
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in