Probably the SessionDelegates should honor the ISessionImplementor contract. Afaik, this the common ground for the Session implementations (statefull and stateless).
Cheers, Henry Conceição On Thu, Dec 9, 2010 at 9:10 AM, Maximilian Raditya <[email protected]> wrote: > OK, so now I've implemented ISessionManager.OpenStatelessSession(). Thanks > to Henry for committing it in the Castle trunk. > > Now, I have a new problem with it over DetachedCriteria with the following > error message: > > Unable to cast object of type > 'Castle.Facilities.NHibernateIntegration.StatelessSessionDelegate' to type > 'NHibernate.Engine.ISessionImplementor'. > > It's reproduced using the following test: > > [Test] > public void TestTransactionStatelessUsingDetachedCriteria() > { > > RootService service = container.Resolve<RootService>(); > > string blogName = "Delicious Food!"; > > > > var blogA = service.CreateBlogStatelessUsingDetachedCriteria(blogName); > Assert.IsNotNull(blogA); > > > var blogB = service.FindBlogStatelessUsingDetachedCriteria(blogName); > > Assert.IsNotNull(blogB); > > Assert.AreEqual(blogA.Name, blogB.Name); > } > > > > [Transaction] > public virtual Blog FindBlogStatelessUsingDetachedCriteria(string name) > > { > DetachedCriteria dc = DetachedCriteria.For<Blog>(); > dc.Add(Property.ForName("Name").Eq(name)); > > > var session = this.SessionManager.OpenStatelessSession(); > > ////return dc.GetExecutableCriteria(((StatelessSessionDelegate) session).InnerSession).UniqueResult<Blog>(); > > return dc.GetExecutableCriteria(session).UniqueResult<Blog>(); > } > > AFAIK, it seems to be related to an old issue with > ISessionManager.OpenSession() which is discussed here: > http://forum.castleproject.org/viewtopic.php?t=2002. As hammett suggested, > to workaround the issue by accessing the ISession directly from > SessionDelegate. So, if I uncommented this line (return > dc.GetExecutableCriteria(((StatelessSessionDelegate) > session).InnerSession).UniqueResult<Blog>();), it would just work. > > Actually, I'm confused and wondering how it can work and cannot. Is that > related to NHibernateFacility itself or NHibernate directly? > > Thanks. > > > > > -- > Regards, > > Maximilian Haru Raditya > > > > > > 2010/11/22 Henry Conceição <[email protected]> >> >> I didn't put much thinking on it, but I think that a >> StatelessSessionDelegate, implementating both interfaces (ISession and >> IStatelessSession) would be the simplest thing on this situation, >> since you could reuse the current machinery for session >> store/management. >> >> Cheers, >> Henry Conceição >> >> >> >> On Sun, Nov 21, 2010 at 4:10 AM, Maximilian Raditya <[email protected]> >> wrote: >> > Hi everybody, >> > >> > I've recently proposed a suggestion to add OpenStatelessSession in >> > ISessionManager of NHibernate Facility >> > (http://issues.castleproject.org/issue/FACILITIES-142). Henry said >> > patchs >> > are always welcome, so I decide to try it myself. >> > >> > I've downloaded the source code (by cloning it; I'm new to Git). I'm new >> > to >> > the source code and I'm trying to understand it. Based on my >> > understanding, >> > it seems a lot of work need to be done to add IStatelessSession support. >> > >> > For starting point, I've added OpenStatelessSession() in ISessionManager >> > and >> > DefaultSessionManager (just the signature, not the implementation yet). >> > And >> > then I wonder what the next step should be. >> > >> > In OpenSession() implementation, I found SessionDelegate and >> > ISessionStore. >> > My questions for now: >> > >> > it seems I should create StatelessSessionDelegate, right? >> > should I create a separate IStatelessSessionStore interface or add >> > FindCompatibleStatelessSession in ISessionStore? >> > >> > Here the link to my Git commit: >> > >> > https://github.com/mahara/Castle.Facilities.NHibernateIntegration/commit/3cd576a8fb06705440ea85729c1bf34952da6668. >> > It's just the initial signature, not the implemetation yet. >> > >> > I hope someone willing to help me on doing this. >> > >> > Thanks. >> > >> > >> > >> > >> > -- >> > Regards, >> > >> > Maximilian Haru Raditya >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Castle Project Development List" 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-devel?hl=en. >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Castle Project Development List" 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-devel?hl=en. >> > > > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Development List" 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-devel?hl=en. > -- You received this message because you are subscribed to the Google Groups "Castle Project Development List" 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-devel?hl=en.
