title: NHibernate Subclass of a Joined-Subclass problem
body: <p>I have an application that has a core assembly with base classes that I need to inherit from.. I need to save these to the database and after reading about NHibernate decided to use it.</p>
  
  <p>However I have a problem with one of my new inherited classes..  I have setup the subclass map but when I save, it neither attempts to save any of it's base class properties or any of it's new ones that I have assigned in the mapping!</p>
  
  <p>My classes are laid out like the following: (from a small demo app)</p>
  
  <p>core assemblies
  DataItem -> User</p>
  
  <p>Anything that will touch the database inherits the DataItem class as it handles the id, modified date etc etc.. </p>
  
  <p>In my test I setup user to only have a FirstName.. </p>
  
  <p>If I save a new User it works great.. however when I inherit from user and then add another property called LastName and attempt to save this new object.. it only puts a sql statement together of INSERT INTO t_User (id) VALUES(?).. it doesn't attempt to save the first name or last name.. either though both have been set and are mapped.</p>
  
  <p>My nhibernate.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt;
    &lt;session-factory name="DAL"&gt;
      &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2005Dialect&lt;/property&gt;
      &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt;
      &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt;
      &lt;property name="adonet.batch_size"&gt;16&lt;/property&gt;
      &lt;property name="current_session_context_class"&gt;web&lt;/property&gt;
      &lt;property name="proxyfactory.factory_class"&gt;NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle&lt;/property&gt;
      &lt;mapping assembly="DAL"/&gt;
      &lt;mapping assembly="NHibernateDemo"/&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>As you can see I have 2 assemblies.. my DAL is my core and the NHibernateDemo is a web application that uses the core for inheritance.</p>
  
  <p>My core DataItem mapping:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DAL" namespace="DAL.Model"&gt;
    &lt;class name="DataItem" table="t_DataItem" &gt;
      &lt;id name="Id"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;discriminator column="typeid" type="System.Int32"&gt;&lt;/discriminator&gt;
      &lt;property name="IsActive" column="isActive" not-null="true" /&gt;
      &lt;property name="TypeId" column="typeId" not-null="true"&gt;&lt;/property&gt;
      &lt;many-to-one name="Parent" column="ParentId" class="DataItem"&gt;&lt;/many-to-one&gt;
      &lt;bag name="Children" cascade="all-delete-orphan"&gt;
        &lt;key column="ParentId"&gt;&lt;/key&gt;
        &lt;one-to-many class="DataItem"/&gt;
      &lt;/bag&gt;
      &lt;joined-subclass name="User" table="t_Users"&gt;
        &lt;key column="id"&gt;&lt;/key&gt;
        &lt;property name="FirstName" column="firstName" not-null="true" &gt;&lt;/property&gt;
      &lt;/joined-subclass&gt;
      &lt;joined-subclass name="Email" table="t_Emails"&gt;
        &lt;key column="emailid"&gt;&lt;/key&gt;
        &lt;property name="Address" column="Address"&gt;&lt;/property&gt;
      &lt;/joined-subclass&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>My inherited NewUser mapping that doesn't work!:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernateDemo" namespace="NHibernateDemo.Model"&gt;
    &lt;subclass name="NewUser" extends="DAL.Model.User, DAL" discriminator-value="1"&gt;
      &lt;property name="LastName" column="LastName"&gt;&lt;/property&gt;
    &lt;/subclass&gt;
  </code></pre>
  
  <p>Why is it that when I attempt to save my class NewUser that it doesn't attempt to save any of the other properties set, whether from it's base or newly declared properties?</p>
  
  <p>I'd really appreciate any help or insight to this.. I must be missing something really simple and I just can't see it.</p>
  
  <p>Thanks,</p>
  
  <p>Mike
      </p>