AR is based on NHibernate. NHibernate (NH) is session-based, which means
that if you use NH without AR, you always need a ISession object to load or
save objects.AR creates ISession objects on the fly when you call the
ActiveRecord persistance methods (entity.Save() etc.). Now when an object is
lazily loaded, a proxy is loaded instead and it keeps a reference to the
ISession object that were used to load the proxy.
When you now access the proxy (you don't know that, for you the proxy IS the
loaded child object), the proxy hydrates itself by using the stored ISession
to load the real values from the database. But by then, the ISession was
already disposed and the connection closed, hence the exception.
The SessionScopeWebModule now sets a SessionScope up in the background that
holds the ISession. Therefore not every call creates a new ISession but uses
the SessionScopes ISession instead. As a result, proxy can use that ISession
until the SessionScope is disposed, in this case at the end of the web
request.

-Markus

2009/10/15 Maia <[email protected]>

>
> Hello!
>
> I upgraded the AR 1.0 to the AR version 2.0 and after of install and
> upgrade the system, when I go to run it shows me the following error:
>
> Initializing[CRMModel.Model.CrmProspect#1]-failed to lazily initialize
> a collection of role: CRMModel.Model.CrmProspect.contatoRealizado, no
> session or session was closed
>
> In version 1.0 this error also occurred, but after put the line below:
> <httpModules>
>    <add name="ar.sessionscope"
> type="Castle.ActiveRecord.Framework.SessionScopeWebModule,
> Castle.ActiveRecord"/>
> </httpModules>
>
> After setting this line in the web.config the error didn't happen
> anymore.
> Does anyone have any tip?
> Thanks attention!
> Maia
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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