Hitting the same problem.
Using spring to configure:
Code:
<property name="eventListeners">
<map>
<entry key="post-load">
<bean class="my.package.dao.PersistedEntityPostLoadListener"/>
</entry>
...
The collection mapping:
Code:
@OneToMany(mappedBy="accountSheet", cascade=CascadeType.ALL,
targetEntity=AbstractAccount.class, fetch=FetchType.EAGER)
public Set<Account> getAccounts() {
This happens when I iterate over the collection from the post-load listener:
Code:
26-Mar-2008 11:46:36 org.hibernate.LazyInitializationException <init>
SEVERE: illegal access to loading collection
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
at my.package.domain.account.AccountSheet.onPostLoad(AccountSheet.java:151)
at my.package.dao.PersistedEntityPostLoadListener.onPostLoad(PersistedEntityPostLoadListener.java:15)