Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6u469kis46DspusiL
15 lines
750 B
Plaintext
15 lines
750 B
Plaintext
== Q25: N+1 selects ==
|
|
data: 5 customers, 12 orders (4 customers x 3 orders, plus one customer with none)
|
|
lazy loop (default) : total = 2400, SQL statements = 6
|
|
JOIN FETCH query : total = 2400, SQL statements = 1
|
|
@EntityGraph("orders") : total = 2400, SQL statements = 1
|
|
== Q26: LazyInitializationException ==
|
|
no @Transactional around the loop -> LazyInitializationException
|
|
message: Cannot lazily initialize collection of role 'com.ankurm.interviewlab.exp23.spring.Customer.orders' with key '1' (no session)
|
|
== Q27: a DTO projection with LEFT JOIN ==
|
|
OrderTotal[name=Asha, total=600]
|
|
OrderTotal[name=Kiran, total=600]
|
|
OrderTotal[name=Meera, total=600]
|
|
OrderTotal[name=Nobody, total=0]
|
|
OrderTotal[name=Ravi, total=600]
|