Your problem is in the NHibernateSessionManager. Your comment in the code at the start of the file about storing a SessionFactory is what you should be doing, but you are storing and trying to reuse the Session.....
You can safely put the SessionFactory object in a singleton and reuse it. I also started with the code by Bill Mcafferty, but have come to understand that the Session is itself the correct UnitOfWork, especially when in a web context. You should do some form of load testing before you deploy to production, as that would show these issues at an early stage, even if it is only multiple computers running a browser against a web server for testing it should be sufficient. John Davidson On Wed, Oct 20, 2010 at 5:07 PM, MattO <[email protected]> wrote: > Well I thought I was implementing the this properly. But your > statement saying "This can happen when storing a reference in a > singleton" might be what is happening. > > I've placed my session implementation here: > http://www.keelio.com/session.zip > > There are two .cs files in there. > > My manager objects call NHibernateSessionManager.Instance.Session and > stores it locally as a protected INHibernateSession variable. > > NHibernateSessionManager.Instance.Session is stored as a static > property: > > public static INHibernateSessionManager Instance > > I get an instance of my manager many times throughout the application, > which I believe just pulls the ISession object out of > httpcontext.current.items. > > Perhaps if there is a good example of this out there I can narrow into > my issue. > > On Oct 20, 3:43 pm, John Davidson <[email protected]> wrote: > > Have you created your own SessionManager or UnitOfWork implementation? > Doing > > so may mean that you are trying to use a session after it is no longer > > valid, or when it is being used by another thread. This can happen when > > storing a reference in a singleton. > > > > John Davidson > > > > > > > > On Wed, Oct 20, 2010 at 4:38 PM, MattO <[email protected]> wrote: > > > Maybe I'm running into this, because I've been receiving all of these > > > types of errors describe in this article: > > >http://www.meadow.se/wordpress/?p=286 > > > > > On Oct 20, 3:20 pm, MattO <[email protected]> wrote: > > > > So I've deployed my ASP .NET application to production and low and > > > > behold there are some very strange errors happening. Stack traces > are > > > > almost useless to figure out whats going on. The first error that > > > > happens is as follows. Notice the inner stack trace, why is it > > > > erroring on one of the nHibernate generated Aliases??? > > > > > > could not execute query [ SELECT this_.ExamTypeAccessID as > > > > ExamType1_8_0_, this_.TS as TS8_0_, this_.domainuser as > > > > domainuser8_0_, this_.ExamType as ExamType8_0_, this_.ExamTypeID as > > > > ExamTypeID8_0_ FROM ItemBank.dbo.[ott_ExamTypeAccess] this_ WHERE > > > > this_.domainuser = @p0 ] Positional parameters: #0>domain\user [SQL: > > > > SELECT this_.ExamTypeAccessID as ExamType1_8_0_, this_.TS as TS8_0_, > > > > this_.domainuser as domainuser8_0_, this_.ExamType as ExamType8_0_, > > > > this_.ExamTypeID as ExamTypeID8_0_ FROM ItemBank.dbo. > > > > [ott_ExamTypeAccess] this_ WHERE this_.domainuser = @p0] > > > > > > at NHibernate.Loader.Loader.DoList(ISessionImplementor session, > > > > QueryParameters queryParameters) > > > > at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor > > > > session, QueryParameters queryParameters) > > > > at NHibernate.Loader.Loader.List(ISessionImplementor session, > > > > QueryParameters queryParameters, ISet`1 querySpaces, IType[] > > > > resultTypes) > > > > at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList > > > > results) > > > > at NHibernate.Impl.CriteriaImpl.List(IList results) > > > > at NHibernate.Impl.CriteriaImpl.List[T]() > > > > at > > > > > > ItemBankCoreNH.ManagerObjects.ExamTypeAccessManager.GetAllAssignedExamPermissions(String > > > > domainuser) > > > > at ItemBankWeb.ItemBankMasterPage.Page_Load(Object sender, EventArgs > > > > e) > > > > > > Inner Stack Trace: ExamType1_8_0_ > > > > > > at NHibernate.Loader.Loader.DoList(ISessionImplementor session, > > > > QueryParameters queryParameters) > > > > at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor > > > > session, QueryParameters queryParameters) > > > > at NHibernate.Loader.Loader.List(ISessionImplementor session, > > > > QueryParameters queryParameters, ISet`1 querySpaces, IType[] > > > > resultTypes) > > > > at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList > > > > results) > > > > at NHibernate.Impl.CriteriaImpl.List(IList results) > > > > at NHibernate.Impl.CriteriaImpl.List[T]() > > > > at > > > > > > ItemBankCoreNH.ManagerObjects.ExamTypeAccessManager.GetAllAssignedExamPermissions(String > > > > domainuser) > > > > at ItemBankWeb.ItemBankMasterPage.Page_Load(Object sender, EventArgs > > > > e) > > > > > -- > > > 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]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text - > > > > - Show quoted text - > > -- > 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]<nhusers%[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.
