Skip to content
Ameen Abozaid
Planned lessonJNR-027-L04

Demo: watching the persistence context with SQL logging

  • Lesson 4 of 4
  • Junior
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

see when SQL really runs; prepares JNR-027-LAB1 and JNR-028.

Draft outline details

Step by step

  1. Enable spring.jpa.show-sql (or logging.level.org.hibernate.SQL=DEBUG) in a throwaway sandbox project.
  2. Call find twice for the same id inside one transaction; count the selects (one).
  3. Change a field on the loaded entity and print a marker line before the transaction ends; show the update appears after the marker, at commit.
  4. Planned mistake: call find outside any transaction and change a field; show nothing is saved, then add a transaction.
  5. Summarize: identity map avoided a query, unit of work delayed the update.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.