Files
java-interview-lab/hibernate-jpa/output/q22-lazy-initialization-exception.txt
T

4 lines
354 B
Plaintext

read a lazy collection after the session closed -> org.hibernate.LazyInitializationException: Cannot lazily initialize collection of role 'lab.hibernate.model.Department.employees' with key '1' (no session)
cure 1: fetch it inside the query -> 3 employees, 1 SQL statement
cure 2: ask for exactly the columns you need -> [E11, E12, E13], 1 SQL statement