First time user! Hope someone could point me into the right direction here. 
Just recently started to use NHibernate 
and I'm having problems getting the following to map correctly.

I am using mapping by code.
This is my class structure to start with

public class Entity<TPrimaryKey>

{
  public virtual TPrimaryKey Id { get; protected set; }
}


public abstract class EntityParent<TPrimaryKey> : Entity<TPrimaryKey>
{
  public virtual IList<EntityVersion<TPrimaryKey>> Versions { get; set; };

}


public class EntityVersion<TPrimaryKey> : Entity<TPrimaryKey>
{
  public virtual EntityParent<TPrimaryKey> Parent { get; set; }
}


I have two concrete implementations of this 

    public class Parent : EntityParent<long>
    {
        public virtual string Name { get; set; }
    }


    public class Child : EntityVersion<long>
    {
        public virtual string Name { get; set; }
    }



I have two separate mapping files. one for each class.

Parent

    public class ParentMap: ClassMapping<Parent>
    {
        public ParentMap()
        {
            Id(x => x.Id);
            Property(x => x.Name);
            Bag(p => p.Versions,
                map =>
                {
                    map.Key(km => km.Column("`ParentId`"));
                    map.Access(Accessor.NoSetter);
                    map.Cascade(Cascade.Persist);
                    map.Inverse(true);
                },
                m => m.OneToMany()
                );
        }
    }


Child

    public class ChildMap: ClassMapping<Child>
    {
        public PaymentMethodVersionMap()
        {
            Id(x => x.Id);
            ManyToOne(x => x.Parent, m => m.Column("`ParentId`"));
            Property(x => x.Name);

        }
    }


When I run this I get the following exception

Result Message: 
System.TypeInitializationException : The type initializer for '*****'
---- NHibernate.MappingException : Association references unmapped class: 
Child[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]]
Result StackTrace: 
....
----- Inner Stack Trace -----

   at NHibernate.Cfg.XmlHbmBinding.CollectionBinder.BindCollectionSecondPass
(ICollectionPropertiesMapping collectionMapping, Collection model, 
IDictionary`2 persistentClasses, IDictionary`2 inheritedMetas)
   at NHibernate.Cfg.XmlHbmBinding.CollectionBinder.<>c__DisplayClass13.<
AddCollectionSecondPass>b__12(IDictionary`2 persistentClasses)
   at NHibernate.Cfg.Configuration.SecondPassCompile()
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
****


I'm lost at what I'm doing wrong here. Can anyone point me into the right 
direction? Do I really need to map the Child class separately? 

/BR

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to