-->
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: NHibernate supports long-lived contexts, I don't think so?
PostPosted: Sun Jul 02, 2006 9:06 am 
Newbie

Joined: Mon Jun 19, 2006 2:09 pm
Posts: 4
Hibernate version: 1.2 Alpha

Hi
In the main page of nhibernate exactly in the key features section,there were written:
Quote:
Support for "conversations" - NHibernate supports long-lived persistence contexts, detach/reattach of objects, and takes care of optimistic locking automatically


But i did not read any post in the forums that supports the long-lived sessions , so i thought that there may be a catch that i don't know.
So please tell me the main troubles that would happen if i let one session open for the entire application running time (Performance impacts,memory impacts,exceptions,etc..).

PS:I am using Windows Forms 2.0 not Asp nor Web Services

I know that were mentioned before 1000 times but i am totally messed-up.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 02, 2006 7:25 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
First you have to do a clear distinction between a SessionFactory and a Session.
You would like to keep your SessionFactory for the lifetime of the application.
It is thread safe and an expensive object to build.
On the other hand a session is not thread safe and not exception safe. This means that if your session throws an exception you should close it immediately.
In your winforms app you should have a session per operation or another usage pattern but not a session for the lifetime of the application. Also an open session keeps an open connection to the database and you would not want to do that.
The meaning of the "conversation" paragraph in the docs is that you can load an object in one session, close the session but keep that object in the memory. In another operation (and a fresh session)you can save the object in the db. This means that the lifetime of your persisted object is longer than the lifetime of any individual session.

HTH,
radu


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.