RSS Amplifier

Engineering With Java · Aug 4, 2026

Spring Boot Interview Quiz: What Happens to the Transaction?

0
Sign in to vote or save

Suraj Mishra · Engineering With Java

Consider the following service:

The application throws:

java.io.IOException: Inventory service unavailable

The API returns an error.

A. The order insert is rolled back because an exception occurred.

B. The order insert is committed because IOException is a checked exception.

C. Spring automatically retries the transaction.

D. The transaction remains open until the application restarts.

📢 Get actionable Java and Spring Boot insights every week, including practical code tips and real-world, use-case-based interview questions, to help you level up your backend skills—join 8100+ subscribers for hand-crafted, no-fluff content.

Founding Member Offer: Lock in founding member price at $50/year (~$4/month) for life. Limited spot left

So far we have covered 70+ real world based interview questions and will add up to 100 by end of this year.

Testimonials

B. The order insert is committed because IOException is a checked exception.

A common misconception is:

“Any exception causes a transaction rollback.”

That’s not how Spring works.

By default, Spring rolls back transactions only for:

  • RuntimeException

  • Error

Checked exceptions (such as IOException, SQLException, or any class extending Exception) do not trigger an automatic rollback.

Even though the API fails, the database transaction is committed.

Read the original on javabulletin.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.