-->
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.  [ 2 posts ] 
Author Message
 Post subject: LazyInitializationException: illegal access to loading colle
PostPosted: Sat Aug 19, 2006 1:49 pm 
Newbie

Joined: Sat Aug 19, 2006 1:42 pm
Posts: 3
in a nutshell, i have an entity w/ a one-to-many (eager fetching) list of child entities. i also have a transient Map i want to populate for constant-time lookup of the children

in a @PostLoad, i iterate over children and place them in the Map.
however, the PostLoad causes a
org.hibernate.LazyInitializationException: illegal access to loading collection
because apparently hibernate invokes the callbacks before the collections are initialized.

is there any way around this?
or is there a different strategy for accomplishing what i need (lookup into the list)

thx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 8:31 pm 
Newbie

Joined: Wed Aug 23, 2006 10:11 am
Posts: 9
One cheap hack is to load the map on first access:

Code:
public Map getTheMap()
{
    if(theMap == null) {
        loadTheMap();
    }
    return theMap;
}


I know it's ugly, but if you can't find anything else . . .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.