← Fidelity Interview Insights

Fidelity·Backend Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Technical phone screen for a backend role at Fidelity, focused pretty heavily on Spring internals. One question, but it had a lot of layers and I definitely didn't cover all of them cleanly.

Questions Asked (1)

Q1

How do @Transactional's rollbackFor and noRollbackFor attributes work, including their default behavior, how they interact when both are set, and what common pitfalls exist around them?

Technical Trade-offsAPI & IntegrationsSystem Design
Author's notes

I knew the basics: Spring only rolls back on RuntimeException and Error by default, checked exceptions slip through unless you explicitly add them via rollbackFor.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the default rollback behavior (only unchecked exceptions) and how rollbackFor/noRollbackFor override it. Then describe the interaction when both are set, emphasizing that noRollbackFor takes precedence. Finally, highlight common pitfalls such as self-invocation, checked exceptions, and nested transactions.

Pro tip: Mention that rollbackFor and noRollbackFor are evaluated at the method level, and if both are specified, noRollbackFor wins—this shows deep understanding. Also, note that these attributes only apply to the outermost transaction when using propagation REQUIRED, which is a common gotcha.

1. Explain default rollback behavior

By default, Spring rolls back only on unchecked exceptions (RuntimeException and Error). Checked exceptions do not trigger a rollback unless explicitly configured.

2. Describe rollbackFor and noRollbackFor

rollbackFor specifies exceptions that should trigger a rollback, while noRollbackFor specifies exceptions that should not trigger a rollback. Both accept an array of Class objects.

3. Explain interaction when both are set

If both are set, noRollbackFor takes precedence over rollbackFor. So if an exception matches both, no rollback occurs.

4. Highlight common pitfalls

Pitfalls include: self-invocation bypassing proxy, checked exceptions not rolling back by default, rollback rules only applying to the outermost transaction, and misunderstanding propagation effects.

Key Points to Mention

  • Default rollback only on unchecked exceptions (RuntimeException and Error).
  • rollbackFor and noRollbackFor can be used to customize rollback behavior for checked exceptions.
  • When both are specified, noRollbackFor takes precedence.
  • Self-invocation (calling a @Transactional method from within the same class) bypasses the proxy, so rollback rules are not applied.
  • Rollback rules are only applied to the outermost transaction when propagation is REQUIRED or REQUIRES_NEW.
  • Checked exceptions do not trigger rollback unless explicitly configured with rollbackFor.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.