Hibernate LazyInitializationException: could not initialize proxy — no Session

Accessed a `LAZY` JPA association outside an active `@Transactional` persistence context.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: Hibernate LazyInitializationException Platform: Java
Common Root Causes:
  • Accessed a `LAZY` JPA association outside an active `@Transactional` persistence context.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Fetch required associations explicitly via `JOIN FETCH` or `@EntityGraph` inside the repository query.
Safe Diagnostic Command:
Inspect controller/DTO serialization trace
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Accessed a `LAZY` JPA association outside an active `@Transactional` persistence context. Recommended diagnostic: `Inspect controller/DTO serialization trace`. Remediation: Fetch required associations explicitly via `JOIN FETCH` or `@EntityGraph` inside the repository query.

Worked Examples

  • Run `Inspect controller/DTO serialization trace` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-spring-hibernate-lazyinitialization · Independently verified: 2026-11-25

Related Resources