Loading lesson…
Level 1 · Apprentice0 XP
See how one list screen fires 101 queries, and how to make it fire 1.
Step 1 / 5
ProblemYou load 100 orders, then print each order's customer name. JPA loads the customer lazily on first access, one query per order. It is fast in dev with five rows and crawls in production.
← → step
Before this: Spring Data JPA
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Turn on SQL logging (spring.jpa.show-sql=true). Load a list of entities and touch a lazy relation in a loop. Count the queries. Fix it with a fetch join and count again.