Hi..
I've already go through you SessionFactory code.. and just want to know is it true singleton class?..
Where you store your _sessionfactory reference? i'm also check your NHSessionModule and find you add your reference into Context.Items.Add which means every request will create new configution class....
Yes, the SessionFactory in Cuyahoga is a true singleton class. There will be only one instance of it in one appdomain.
The NHSessionModule creates an instance of the CoreRepository. The CoreRepository in its turn obtains a reference to the single SessionFactory instance and manages the NHibernate Sessions.
This means that at every request, a new CoreRepository is created (Session per Request) but the SessionFactory stays in memory (referenced by itself).
martijnbThis means that at every request, a new CoreRepository is created (Session per Request) but the SessionFactory stays in memory (referenced by itself).
What do you mean reference by itself... as we know webserver is a stateless connnection.. that means you need to add nhibernate session reference in .Net session for using is other request..but if you using Context.Item.Add it's lifecycle only per request...
Hmmm, I should be more clear about this:
The SessionFactory is a Singleton. The instance will stay alive within the ASP.NET process until the process is recycled. Keep in mind that although a web application is stateless, the server process doesn't quit after each request. It's just a running application.
At each request the SessionFactory will create a new NHibernate Session that is stored in the Context.Items collection (via the CoreRepository) and will be alive only during the request.
Does that make sense?