Problem: org.hibernate.LazyInitializationException

Why?

The LazyInitializationException occurs when attempting to access un-fetched data (represented by a proxy) from the database in a detached manner (outside the Hibernate session scope). This is tied to Hibernate’s default fetching policies for entity relationships.

Default Fetching Policies in JPA/Hibernate

One-to-Many: LAZY

When Does LazyInitializationException Occur?


Solutions

1. Change Fetching Policy to EAGER