Hi,
I'm experiencing another problem related to proxied class. We've implemented session-per-request approach for using NHibernate in ASP.NET code. When I have an NH object loaded from session1 (the object turns out to be a proxy), and make changes to it in session2 and call session.SaveOrUpdateCopy(object), then I get the exception below from NHibernate. If I remove the proxy from the mapping, then all works fine. Can some please help?
Thanks.
Exception:
NHibernateMessage: No persisters for: CProxyTypeSamplingReportTemplate_INHibernateProxy1Stack trace: at NHibernate.Impl.SessionFactoryImpl.GetPersister(Type theClass)
at NHibernate.Impl.SessionImpl.GetPersister(Type theClass)
at NHibernate.Impl.SessionImpl.DoCopy(Object obj, Object id, IDictionary copiedAlready)
at NHibernate.Impl.SessionImpl.SaveOrUpdateCopy(Object obj)
at WaterTrax.WTX.BusinessObj.SampleReportTemplates.SampleTemplates.UpdateReportTemplate(SamplingReportTemplate cTemplate)
Mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="WaterTrax.WTX.WTXObjectModel.SamplingReportTemplates.SamplingReportTemplate, WTXObjectModel" table="tSampSchedReportTemplate" proxy="WaterTrax.WTX.WTXObjectModel.SamplingReportTemplates.SamplingReportTemplate, WTXObjectModel">
<id name="SampSchedReportTemplateID" column="SampSchedReportTemplateID" unsaved-value="0">
<generator class="identity" />
</id>
<set name="SampSchedReportFilter" cascade="all-delete-orphan" inverse="true" >
<key column="SampSchedReportTemplateID" />
<one-to-many class="WaterTrax.WTX.WTXObjectModel.SamplingReportTemplates.SampSchedReportFilter, WTXObjectModel" />
</set>
<set name="SampSchedReportColumn" cascade="all-delete-orphan" inverse="true" >
<key column="SampSchedReportTemplateID" />
<one-to-many class="WaterTrax.WTX.WTXObjectModel.SamplingReportTemplates.SampSchedReportColumn, WTXObjectModel" />
</set>
<property name="FacilityID" column="FacilityID" />
<property name="ReportName" column="ReportName" />
<property name="ReportDesc" column="ReportDesc" />
<property name="ReportTemplateName" column="ReportTemplateName" />
<property name="BeginDate" column="BeginDate" />
<property name="EndDate" column="EndDate" />
<property name="IncludesFilterSummary" column="IncludesFilterSummary" />
<property name="IncludesRecordsEvents" column="IncludesRecordsEvents" />
<property name="ReportType" column="ReportType" />
<property name="GroupByOption" column="GroupByOption" />
<property name="CompletionStatusOption" column="CompletionStatusOption" />
<property name="OutputOption" column="OutputOption" />
<property name="SubtotalOption" column="SubtotalOption" />
<property name="CollectionDateOption" column="CollectionDateOption" />
</class>
</hibernate-mapping>