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: ASP.NET MVC one Session per request
PostPosted: Tue Sep 01, 2009 5:14 pm 
Newbie

Joined: Tue Sep 01, 2009 5:00 pm
Posts: 3
Ok... I know this question has been posted many times, but I am still having issues. Here's the context of my situation. I am working with the Asp.Net MVC 1.0 framework with NHibernate (duh) and Spring.NET. Currently I am unable to work with a single hibernate session per request. When calling: SessionFactory.GetCurrentSession() I receive the error "No CurrentSessionContext configured ( ... )".

I have added the "OpenSessionInViewModule" within the <httpModules> section of my web.config. If I understand things correctly, this will aid in the one-session-per-request idea.

My spring context file that defines the session factory looks something like this...

...

<object id="sessionFactory" ...>
<property name="DbProvider" ref="DbProvider"/>
<property name="HibernateProperties">
<dictionary>
<entry key="connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="dialect"
value="NHibernate.Dialect.MsSql2005Dialect"/>
<entry key="connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"/>
<entry key="show_sql" value="true"/>
<entry key="hbm2ddl.auto" value="create"/>
<entry key="current_session_context_class" value="Web" />
</dictionary>
</property>
</object>

...

The entry of concern is "current_session_context_class". What should the value be? "thread", "thread_static" or "web"? Everyone seems to have a different answer to this question.

From what I gather by reading docs and blogs, I should be good to go at this point, but like I mentioned earlier the call to SessionFactory.GetCurrentSession() throws an exception. If I just use SessionFactory.OpenSession(), life is great and I can save/update objects to the database, but obviously this is opens a different session every time.

Suggestions? I appreciate the help!

Bryan


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.