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: Suggestion: Raise an event before, and after a lazy init.
PostPosted: Mon Feb 11, 2008 5:50 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 4:47 am
Posts: 25
In a data-bound win-forms environment, I'm having NHibernate lazy load a collection.
When I disconnect the session, I get a LazyInitializationException - understandably.

So - To get round this problem, is it as simple as having AbstractPersistentCollection raise an event, before and after it initialises the colelction?

Code:

Fire BeforeLaztInitialise event here

if (session.IsConnected)
{
   try
   {
      session.InitializeCollection(this, writing);
   }
   catch (Exception e)
   {
      log.Error("Failed to lazily initialize a collection", e);
      throw new LazyInitializationException("Failed to lazily initialize a collection", e);
   }
}
else
{
   throw new LazyInitializationException("Failed to lazily initialize a collection - session is disconnected");
}

Fire AfterLazyInitialise event here.


This would allow the app to re-connect to the session, have NHibernate load the lazy collection, and then disconnect if necessary.

Or is there another way to do this ?

Thanks


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.