Hi,
I understand the functioning, but in the AR version 1.0 had the same
error and the soluction found in the Forum was to insert line below
into web.config:
<add name="ar.sessionscope"
type="Castle.ActiveRecord.Framework.SessionScopeWebModule,
Castle.ActiveRecord"/>
With this line in the web.config the sistem worked without erros.
After upgrade to A version 2.x and NH 2.x, the error returned and I
could only solve by inserting the SessionScope in the code as follow
below:
public static CrmSubItem[] RetornarSubItem(int id)
{
using (new SessionScope())
{
CrmItem it = CrmItemController.Retornar(id);
IList s = it.SubItem;
CrmSubItem[] si = new CrmSubItem[s.Count];
int i = 0;
foreach (CrmSubItem sb in s)
{
si[i] = sb;
i++;
}
return si;
}
}
My question is if AR.SESSIONSCOPE of Web.Config didn't work more from
the Version 2.0 of AR and NH?
Thanks attentions!
Maia
On 16 out, 01:22, Markus Zywitza <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---