Skip to content
Ameen Abozaid
Planned lessonJNR-032-L07

Demo: fixing lazy loading without Open Session in View

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

keep lazy relations working with OSIV off; prepares JNR-032-LAB1.

Draft outline details

Step by step

  1. Set spring.jpa.open-in-view=false; call an endpoint that returns an entity with lazy lines.
  2. See LazyInitializationException in the response.
  3. Planned mistake: change the relation to EAGER; show the extra queries everywhere.
  4. Revert; add an entity graph or a DTO projection in the service method.
  5. Return a response DTO built inside the transaction; the exception is gone and the query count is low.

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.