Demo: watching the persistence context with SQL logging
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
- Enable
spring.jpa.show-sql(orlogging.level.org.hibernate.SQL=DEBUG) in a throwaway sandbox project. - Call
findtwice for the same id inside one transaction; count the selects (one). - 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.
- Planned mistake: call
findoutside any transaction and change a field; show nothing is saved, then add a transaction. - Summarize: identity map avoided a query, unit of work delayed the update.
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.