-->
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: Collection Initializaiton
PostPosted: Sun Dec 04, 2005 5:58 pm 
Regular
Regular

Joined: Wed Sep 10, 2003 2:26 pm
Posts: 56
Location: San Diego, CA
I've unsuccessfully tried getting help on this topic before. I really would like to understand what going on with the problem i'm having.

I have a class with a collection property. When the class instance becomes persistant and the collection property is being set, I need to iterate via the collection in order to compute some totals and to index the collection entries by their type into a hashmap. I also need to decorate the collection with an ObservableCollection (using commons-events observable collections).

The problem is that if I try to iterate via this collection when its setter being called by Hibernate I keep getting a " illegal access to loading collection" exception.

I've looked over all documentation and search many times through forum archives but found no explaination on how this works. When exactly a collection becomes available for iterating? Can any answer this question for me? Is there some document I missed?

I'm not using lazy loading, all persistant objects are set to lazy="false" and all collections to fetch="join"

If you need more info about my setup, please see this post: http://forum.hibernate.org/viewtopic.php?t=950439&

Thansk
Dmitry

Hibernate version:
3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2005 11:47 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
As I understand it, the earliest you should modify a loaded object is during its PostLoadEvent. However I don't think that there are any rules about the order in which objects are loaded: just because your nesting class is loaded doesn't mean that all its nested objects are loaded, even when you use fetch="join" lazy="false".

You could put a PostLoadEventListener on the nested class, and decorate each item in the collection as it's being loaded. For the totals/hashmap part, without knowing the internal of the system the best I can suggest is to calculate them when first accessed, instead of on loading. This may also have minor performance benefits if you sometimes don't access those values.


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.