org.hibernate.LazyInitializationException: could not initialize proxy - no Session
A lazy-loaded association was accessed after the Hibernate session/transaction closed.
could not initialize proxy - no Sessionfailed to lazily initialize a collection 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Hibernate ConstraintViolationException org.hibernate.exception.ConstraintViolationException: could not execute statement
- InvalidDefinitionException com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered
- N+1 queries Performance: N+1 query problem (one query per row in a loop)
Most viewed in Java
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026