8 May 2013

Failed to lazily initialize a collection of role: could not initialize proxy - no Session

Problem: When lazy loading in used in Hibernate, it fails to initialize a collection of role.

failed to lazily initialize a collection of role: could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session

Cause: The session was closed, so it can't load the actual contents of the collection.

Solution: add an @Transactional annotation to it, or the entry point from which it is called.

No comments: