Demo: making checkout atomic
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
make "place order" all-or-nothing; prepares JNR-031-LAB1.
Draft outline details
Step by step
- Show
placeOrderwithout@Transactional: stock is reserved, then the order save fails; stock is wrong. - Add
@Transactionalto the service method. - Re-run the failing test: stock is unchanged.
- Planned mistake: throw a checked exception and show the stock change committed; fix with
rollbackFor. - Add
@Transactional(readOnly = true)to the order query method.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.