What you want most of the time is a single session _per_ unit of work, not per application lifetime. This comes naturally in a web application where one request to the server is usually one unit of work - and no persisted objects remains loaded after the request finished anyway. A Forms application can also be internally structured around some kind of request/unit of work pattern, even though it doesn't follow "automatically" from the framework.
/Oskar 2010/9/15 PLen <[email protected]>: > This all started because of the lazy loading property capability, > which makes a database call sometime after the original query. This > forces the need to keep the same session around to use for the lazy > loading. No biggie. The code that puts the session in a "using" > block: > > using (ISession session = NHibernateHelper.OpenSession()) { > } > > was used by me after seeing various examples of it from different web > sites. Now that I need the session to persist, this doesn't seem like > the way to go when dealing with queries. I keep hearing about using a > single session, which would be fine since this is a Windows Form > application, but is there no timeout associated with an ISession that > would cause an error if the session is not used in x minutes/hours? > I'm just worried about what might happen to a session if it is not > used for long periods of time which would trigger some timeout > action. Based on your comment (Oskar), it seems that using a single > session is a common thing to do. Is that the case? I don't mind > doing that. I just want to make sure I am writing my code to general > practices. > > - Peter > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
