Hello Anthony,

Ah, sorry. It's just I don't clearly understand your issue statement as it's
a bit confusing.

Let me paraphrase it to make it clearer:

   1. You're using ISessionManager in web application context (by setting
   isWeb=true).
   2. You're assuming and expecting ISessionManager.OpenSession() to create
   a new single ISession (session) when in fact, based on your observation, it
   didn't it. Instead, it just returns already opened session if such is
   present. You don't expect such behavior and want to open a new session
   everytime you call OpenSession(), instead of returning existing active
   (present) session.
   3. Based on #2, you want to access ISessionFactory directly since it
   would give the behavior you expect.

As for #3, yes, you can access ISessionFactory instead of using
ISessionManager. In the doc here:
http://www.castleproject.org/container/facilities/trunk/nhibernate/index.html,
you can see there are two integration levels (ways) of using NH Facility.
First by using ISessionFactory, and second by using ISessionManager. You
can use both in web application depends on your need.

As for #2, I think it's the expected behavior since the opened session bound
to a single HttpContext request (HttpContext.Current), it would span as long
as it's in a single HttpContext request life time.

Still, I'm not sure what you meant by thread safe.

Hope this helps.




-- 
Regards,

Maximilian Haru Raditya






On Wed, Apr 27, 2011 at 4:52 PM, Anthony Phillips <[email protected]>wrote:


> Hello Maximilian,
>
> Sorry, I don't mean to frown on any work, I believe the integration is
> brilliant. I just figured that when calling OpenSession on the
> ISessionManager, since the resulting call is either Open or
> GetCurrent, I would of assumed that the ISessionManager would be
> thread aware/thread safe since on subsequent calls, on the container,
> it forces it to look for the last ambient session, which could be on
> another thread. If we were given the option to Open a new ISession,
> with ISessionManager, regardless of existing ISession(s) then I would
> of not made that assumption.
>
> Since we can't directly open a new ISession if one is present using
> ISessionManager, do correct me if I am wrong, is the suggestion made
> to me on StackOverflow a sound one? Can I reference the SessionFactory
> from the container using IoC in much the same way I used it in my
> example? I guess that would then solve my issue.
>
> Unless of course, there is a better practice way of using the
> ISessionManager thread-safe? If there is, are there any examples
> anywhere? I have yet to find any and have spent a day looking.
>
> Thanks for your time,
>
> Anthony
>
> On Apr 26, 10:36 pm, Maximilian Raditya <[email protected]> wrote:
> > Hello,
> >
> > I don't honestly understand how you are expecting it to be thread-safe.
> Mind
> > elaborating about it more? I mean what you expect from it to behave, and
> how
> > it doesn't meet your expectation.
> >
> > AFAIK, NHibernate ISession is also NOT thread-safe, but ISessionFactory
> IS
> > thread-safe, as a comparison.
> >
> > --
> > Regards,
> >
> > Maximilian Haru Raditya
> >
>
> > On Wed, Apr 27, 2011 at 1:37 AM, Anthony Phillips <[email protected]
> >wrote:
>
> >
> >
> >
> >
> >
> >
> >
> > > Hello there,
> >
> > > I'm hoping someone can help me and explain the way to do things
> > > properly.
> >
> > > I posted my question here:
> >
>
> > >http://stackoverflow.com/questions/5782696/thread-safe-issue-with-cas.
> ..
>
> >
> > > I see no point in retyping it out but if you have a look at that and
> > > then keep this in mind. How can I use ISessionManager with other
> > > threads?
> >
> > > Thanks,
> >
> > > Anthony
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Castle Project Users" 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/castle-project-users?hl=en.
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" 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/castle-project-users?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en.

Reply via email to