Accessing collection on PostLoad event causes LazyInitializationException

Description

We've encountered a problem using the PostLoad event to access a OneToMany Collection.

Attempting to access the Collection in the PostLoad event handler results in a LazyInitializationException being thrown by AbstractEntityManagerImpl. The stack trace is below:

javax.persistence.PersistenceException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1235)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:631)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:585)

I've attached a JUnit test case containing the classes and configuration. We're using Oracle 11g and Hibernate v3.5.3-Final, but the test case uses HSQLDB.

If there is any further information I can provide to help diagnose this then please let me know.

Attachments

1

Activity

Show:

Brett MeyerMarch 7, 2014 at 5:30 PM

Bulk closing rejected tickets in "resolved" state.

Former userAugust 16, 2011 at 10:52 PM

Making this a duplicate of because that issue has 10 votes.

Duplicate

Details

Assignee

Reporter

Affects versions

Priority

Created July 28, 2010 at 11:50 AM
Updated March 7, 2014 at 5:30 PM
Resolved August 16, 2011 at 10:52 PM