-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: PostLoad callback illegal access to loading collection
PostPosted: Wed Sep 26, 2007 12:53 pm 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
Hi there,
I'm getting a "org.hibernate.LazyInitializationException: illegal access to loading collection" error when trying to manipulate a data set within an entity within the PostLoad method.

This is similar to the PostLoad method convertPhotos in example http://java.boot.by/scbcd5-guide/ch06s04.html

Should this work?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 7:01 am 
Newbie

Joined: Wed Mar 09, 2005 2:46 pm
Posts: 8
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)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 7:09 am 
Newbie

Joined: Wed Jul 04, 2007 9:06 am
Posts: 12
Unforunately I never found a solution, I'd be interested if you find one.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 18, 2008 3:27 am 
Newbie

Joined: Tue Jul 08, 2008 11:09 am
Posts: 12
This bug is filed at the JBoss Jira:

https://jira.jboss.org/jira/browse/JBAS-5474

Please vote for it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 9:11 pm 
Newbie

Joined: Thu Feb 23, 2006 6:44 pm
Posts: 4
Well, the only solution I have found is to make a copy of the collection in the setter and access the copied collection during the @PostLoad method. This is a total hack but it does the trick.

This is a known issue https://jira.jboss.org/jira/browse/JBAS-5474


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 9:22 pm 
Newbie

Joined: Tue Feb 10, 2009 9:19 pm
Posts: 2
thanks for links)
-----------------------------
www.awtoys.com


Top
 Profile  
 
 Post subject: Re: PostLoad callback illegal access to loading collection
PostPosted: Sat Jul 11, 2009 12:01 pm 
Newbie

Joined: Thu Jul 09, 2009 3:15 am
Posts: 1
Is there a solution or workaround for this problem? Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.