Correct. Task is a reference to CubeNet.Service.DomainObjects.Task, NOT 
System.Threading.Tasks.Task

On Thursday, April 16, 2015 at 3:59:32 AM UTC-7, mwpowellhtx wrote:
>
> On Wednesday, April 15, 2015 at 6:41:34 PM UTC-4, brainbolt wrote: 
> > I'm accustomed to seeing "No persister for:" errors when I don't have a 
> class map defined for one of my classes, but not for an internal NHibernate 
> class. 
> > I'm the getting this exception when I attempt to access 
> the Tasks collection defined in the following relationship. It doesn't make 
> a difference if the collection is eager or lazy loaded, except that if it 
> is lazy loaded, the exception isn't thrown until I try to access the 
> collection, so it seems that the exception is the result of NHibernate 
> trying to query for the collection. 
> > I'm using the Fluent API for the mappings, but I've included the 
> resulting hbm.xml file below. 
> > TaskContainer (base class)public abstract class TaskContainer : 
> DomainObject 
> > { 
> >     public virtual IList<Task> Tasks { get; set; } 
> > } 
> > Taskpublic class Task : TaskContainer 
> > { 
> >     public virtual TaskContainer TaskContainer { get; set; } 
> >     public virtual string Description { get; set; } 
> > 
> >     public virtual void AddChildTask(Task childTask) 
> >     { 
> >         if (Tasks == null) 
> >         { 
> >             Tasks = new List<Task>(); 
> >         } 
> > 
> >         childTask.TaskContainer = this; 
> >         Tasks.Add(childTask); 
> >     } 
> > 
> >     public static Task Get(int id) 
> >     { 
> >         return Get<Task>(id); 
> >     } 
> > } 
> > TaskMappublic class TaskMap : ClassMap<Task> 
> > { 
> >     public TaskMap() 
> >     { 
> >         Id(x => x.Id); 
> >         Map(x => x.Description); 
> >         ReferencesAny(x => x.TaskContainer) 
> >             .EntityIdentifierColumn("TaskContainer_Id") 
> >             .EntityTypeColumn("TaskContainerDiscriminator") 
> >             .IdentityType<int>() 
> >             .AddMetaValue<Task>("Task"); 
> >         HasMany(x => x.Tasks) 
> >             .KeyColumns.Add("TaskContainer_Id", 
> "TaskContainerDiscriminator") 
> >             .PropertyRef("TaskContainer") 
> >             .Not.LazyLoad(); 
> >     } 
> > } 
> > Exported hbm.xml map<hibernate-mapping 
> xmlns="urn:nhibernate-mapping-2.2" default-cascade="all"> 
> >   <class xmlns="urn:nhibernate-mapping-2.2" lazy="false" 
> name="CubeNet.Service.DomainObjects.Task, CubeNet.Service, Version=1.0.0.0, 
> Culture=neutral, PublicKeyToken=null" table="`Task`"> 
> >     <id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, 
> Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
> >       <column name="Id" /> 
> >       <generator class="identity" /> 
> >     </id> 
> >     <bag name="Tasks"> 
> >       <key property-ref="TaskContainer"> 
> >         <column name="TaskContainer_Id" /> 
> >         <column name="TaskContainerDiscriminator" /> 
> >       </key> 
> >       <one-to-many class="CubeNet.Service.DomainObjects.Task, 
> CubeNet.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
> >     </bag> 
> >     <property name="Description" type="System.String, mscorlib, 
> Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
> >       <column name="Description" /> 
> >     </property> 
> >     <any id-type="System.Int32, mscorlib, Version=4.0.0.0, 
> Culture=neutral, PublicKeyToken=b77a5c561934e089" meta-type="System.String, 
> mscorlib, Version=4.0.0.0, Culture=neutral, 
> PublicKeyToken=b77a5c561934e089" name="TaskContainer"> 
> >       <meta-value value="Task" 
> class="CubeNet.Service.DomainObjects.Task, CubeNet.Service, 
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
> >       <column name="TaskContainerDiscriminator" /> 
> >       <column name="TaskContainer_Id" /> 
> >     </any> 
> >   </class> 
> > </hibernate-mapping> 
>
> Not to be confused with TPL, threading Task? 
>
> > Saving records with this configuration works as expected and produces 
> the following table with these recordsId  Description 
>  TaskContainerDiscriminator  TaskContainer_Id 
> > --  -----------  --------------------------  ---------------- 
> > 1   Parent task  NULL                        NULL 
> > 2   Child Task   Task                        1 
> > Retrieving the either record works, but the exception is thrown when 
> attempting to access the collection of child records. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Reply via email to