-->
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.  [ 1 post ] 
Author Message
 Post subject: Inconsistent behaviour of ILifecycle.OnLoad
PostPosted: Sun Mar 30, 2008 12:57 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I run into an inconsistent behaviour of ILifecycle.OnLoad depending on the used fetch mode. I use OnLoad to register some events (PropertyChanged events) on the items of a collection after the parent is loaded.

Code:
void ILifecycle.OnLoad( ISession s, object id ) {
     foreach ( T obj in Items )
        obj.PropertyChanged += OnItemPropertyChanged;
}


When I use the default fetch mode it works fine (though the list gets initialized when I access the Items property in the loop). When I use FetchMode.Join, I get an LazyInitializationException in AbstractPersistentCollection.Initialize because the collection is in state "initializing" when I access "Items".

I know that my approach using OnLoad for that may be not the "cleanest" solution, but I couldn't figure out another way to guarantee that the events will be subscribe in every scenario (long story ...).
But I still wonder if when OnLoad is called the collections of the object shouldn't either be "uninitialized" (in case of lazy loading) or "initialized", but not "initializing".

Any thoughts on that ?

Thx for any help !

_________________
--Wolfgang


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

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.