title: Mapping recursive association using nhibernate
body: <p>I have poco class </p>
  
  <pre><code>public class Category : Entity&lt;int&gt;
  {
      public virtual Category Parent;
      public virtual Iesi.Collections.Generic.ISet&lt;Article&gt; Articles {get; set;}
      public virtual Iesi.Collections.Generic.ISet&lt;Category&gt; ChildCategories {get; set;}
  }
  </code></pre>
  
  <p>I'm not sure is this correct mapping for ChildCategories property</p>
  
  <pre><code>public class CategoryMap : ClassMapping&lt;Category&gt;
  {
      public CategoryMap()
      {
         ...
         Set(x =&gt; x.ChildCategories,
            c =&gt; { c.Cascade(Cascade.DeleteOrphans); },
            r =&gt; { r.OneToMany(); }              
         );
      }
  }
  </code></pre>
  
  <p>Any child category can have only one parent. Once more is this correct mapping?
  If you need more information please ask.</p>
  
  <p>Update:
  Exception inner message is following</p>
  
  <pre><code>{"Could not determine type for: xxxx, 
  for columns: NHibernate.Mapping.Column(Parent)"}
  </code></pre>
  
  <p>Update 2:</p>
  
  <pre><code>public class CategoryMap : ClassMapping&lt;Category&gt;
      {
          public CategoryMap()
          {
              Id(x =&gt; x.Id, m =&gt; m.Generator(Generators.GuidComb));
  
              Property(x =&gt; x.Name, m =&gt;
              {
                  m.Length(255);
                  m.NotNullable(true);
              });
  
              Property(x =&gt; x.Parent, m =&gt;
              {
                  //m.NotNullable(true);
              });
  
              Set(x =&gt; x.ChildCategories,
                c =&gt; 
                { 
                  c.BatchSize(25);
                  c.Inverse(true);
                  c.Cascade(Cascade.DeleteOrphans); 
                  c.Key(k =&gt;
                  {
                      k.Column("ParentId");
                  });
                },
                r =&gt; { r.OneToMany(); }              
             );
  
  
              Set(x =&gt; x.Articles,
                c =&gt; { c.Cascade(Cascade.DeleteOrphans); },
                r =&gt; { r.OneToMany(); }
              );            
          }
      }
  </code></pre>
  
  <p>Update 3</p>
  
  <pre><code>Property(x =&gt; x.Parent, m =&gt;
              {
                  m.Column("ParentId");
                  m.NotNullable(true);
              });
  </code></pre>
  
  <p>Error </p>
  
  <pre><code>{"Could not determine type for: xxxx, 
  for columns: NHibernate.Mapping.Column(ParentId)"}
  </code></pre>