So your saying the the code is correct or incorrect?  It's not quite
clear from your response (or I'm being dense :-) )

You say this: You can safely put the SessionFactory object in a
singleton and reuse it.

But then you are saying this in the first paragraph:

but you are storing and trying to reuse the Session.....

So what exactly am I doing wrong?  Does the s#harp framework do it
correctly?  Because I think I could retrofit that code to my
application with a bit of work...

Matt


On Oct 20, 4:44 pm, John Davidson <[email protected]> wrote:
> 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.GetAllAssignedExamPermi­­­ssions(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.GetAllAssignedExamPermi­­­ssions(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%252bunsubscr...@googlegroup­s.com>
> > ­>
> > > > .
> > > > 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.- 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].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to