-->
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: Using a single ISession during page execution?
PostPosted: Tue May 24, 2005 3:31 pm 
Newbie

Joined: Fri May 13, 2005 7:46 pm
Posts: 17
It seems like this would be ideal since lazy-loading requires the original session (I believe).

I also already have a custom Page class that derives from System.Web.UI.Page.

So I'm thinking that a Property like this:

Code:
      ISession _dataSession;
      ISession DataSession {
         get {
            if(this._dataSession == null || !this._dataSession.IsOpen) {
               if(this._dataSession != null) {
                  this._dataSession.Close();
               }

               this._dataSession = Database.GetSession();
            }

            return this._dataSession;
         }
      }

      public override void Dispose() {
         if(this._dataSession != null && this._dataSession.IsOpen) {
            this._dataSession.Close();
         }

         base.Dispose ();
      }


Is a clean way to keep alive a session for lazy-loading, and it trims down on some calls to the SessionFactory.

The downside is that the Session might get a bit bloated, but since it's only alive for the life of the Page, that doesn't seem like a big deal, and the lazy-loading and code-clarity is a bigger concern in most situations I think.

What do you guys think?


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.