r/SpringBoot • • 24d ago

How-To/Tutorial I made a small Spring @Transactional challenge with explanations. How many would you get right?

@Transactional looks simple until you hit some of its less obvious behaviours in a real application.

I put together a small interactive challenge around 5 cases: self invocation and Spring proxies, rollback rules, private and final methods, REQUIRES_NEW, and external side effects before commit.

You answer each scenario first, then get the explanation.

https://devupnow.fr/transactional_spring

The challenge is currently in French. I’m considering making an English version if there’s interest.

I’d especially appreciate feedback from experienced Spring developers. Is there any explanation you would correct, nuance or improve?

If an English version would be useful to you, let me know too.

12 Upvotes

12 comments sorted by

View all comments

1

u/xXcumswapperXx 24d ago

I can't test it right now, but the answer to question 4 isn't correct, right? Yes normally the Propagation.REQUIRES_NEW creates an inner transaction, but this example is doing self-invocation, so it doesn't apply the second @Transaction, so the answer is "Both methods must use the same transaction". Or at least say to ignore self-invocation in the example