org.hibernate.LazyInitializationException: could not initialize proxy - no Session
A lazy-loaded association was accessed after the Hibernate session/transaction closed.
Seen on:
Java
Meaning
Lazy collections and proxies load on first access, which needs an open session. Accessing them in the controller/view or during JSON serialization after the transaction ended fails.
Common causes
- Accessing lazy relations outside @Transactional
- Serializing entities to JSON after the service returns
- Open Session in View disabled
⚡ Quick fix
- Fetch what you need in the query (JOIN FETCH / @EntityGraph)
- Map to DTOs inside the transaction
- Mark the service method @Transactional(readOnly = true)
Detailed fix by platform
Java
@Query("select o from Order o join fetch o.items where o.id = :id")
How to diagnose
- Association — Which relation?
- Boundary — Where does the transaction end?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026