Tagged
#Spring
1 post
-
How to Fix "failed to lazily initialize a collection" in Spring Data JPA and Hibernate
Hibernate's LazyInitializationException ("failed to lazily initialize a collection") is a classic pitfall when reading foreign-key collections outside an active session. This article explains why it happens — fetch types, the session lifecycle, proxy traps — and walks through the recommended `@Transactional` fix plus the `FetchType.EAGER` alternative.