title: How to manage a multiple-level class hierarchy in nhibernate with table per class hierarchy strategy?
body: <p>I am trying to implement my object hierarchy in one table with the "table per class hierarchy" strategy in NHibernate.  I'm getting an error with my NHibernate mapping that can be easily reproduced with a simple example.  The error is:</p>
  
  <pre><code>System.NotSupportedException: Attempting to parse a null value into an sql string (column:activity0_.Type).
  at NHibernate.SqlCommand.InFragment.ToFragmentString() in InFragment.cs: line 109
  at NHibernate.Persister.Entity.SingleTableEntityPersister.DiscriminatorFilterFragment(String alias) in SingleTableEntityPersister.cs: line 551
  </code></pre>
  
  <p>I can reproduce this with the following domain classes:</p>
  
  <pre><code>public interface IActivity
  {
      Guid Id { get; set; }
  }
  
  public abstract class Activity : IActivity
  {
      public DateTime StartTime { get; set; }
      public Guid Id { get; set; }
  }
  
  public class Running : Activity
  {
      public string Where { get; set; }
  }
  
  public class Talking : Activity
  {
      public string ToWhom { get; set; }
  }
  </code></pre>
  
  <p>And the following XML mapping:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     assembly="NHibernateTesting"
                     namespace="NHibernateTesting" &gt;
    &lt;class name="IActivity"
           lazy="false"
           table="Activity"
           discriminator-value="0"
           abstract="true"&gt;
      &lt;id name="Id"&gt;
        &lt;generator class="guid" /&gt;
      &lt;/id&gt;
      &lt;discriminator column="Type" type="Int16" /&gt;
      &lt;subclass name="Activity"
                discriminator-value="1"
                abstract="true"
                lazy="false"&gt;
        &lt;property name="StartTime" /&gt;
      &lt;/subclass&gt;
      &lt;subclass name="Running"
                discriminator-value="2"
                lazy="false"
                extends="Activity"&gt;
        &lt;property name="Where" /&gt;
      &lt;/subclass&gt;
      &lt;subclass name="Talking"
                discriminator-value="3"
                lazy="false"
                extends="Activity"&gt;
       &lt;property name="ToWhom" /&gt;
      &lt;/subclass&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Does anyone have an idea of what I am doing wrong?</p>