title: Fluent NHibernate: map list of abstract class with table per concrete class (union-subclass)
body: <p>I'm having a problem with the following scenario.</p>
  
  <p>My class structure is as follows:</p>
  
  <pre><code>public class Owner
  {
      public virtual Guid Id { get; set; }
      public virtual string Name { get; set; }
      public virtual IList&lt;Vehicle&gt; Vehicles { get; set; }
  }
  
  public abstract class Vehicle
  {
      public virtual long Id { get; set; }
      public virtual string Name { get; set; }
  }
  
  public abstract class PoweredVehicle : Vehicle
  {
      public virtual string EngineType { get; set; }
  }
  
  public class Car : PoweredVehicle
  {
      public virtual int Doors { get; set; }
  }
  
  public class Truck : PoweredVehicle
  {
      public virtual long MaxLoad { get; set; }
  }
  
  public class Bicycle : Vehicle
  {
      public virtual int FrameSize { get; set; }
  }
  </code></pre>
  
  <p>Fluent mappings:</p>
  
  <pre><code>public class OwnerMap : ClassMap&lt;Owner&gt;
  {
      public OwnerMap()
      {
          Id(x =&gt; x.Id).GeneratedBy.GuidComb();
          Map(x =&gt; x.Name);
          HasMany(x =&gt; x.Vehicles);
      }
  }
  
  public class VehicleMap : ClassMap&lt;Vehicle&gt;
  {
      public VehicleMap()
      {
          Id(x =&gt; x.Id).GeneratedBy.HiLo("10");
          Map(x =&gt; x.Name);
          UseUnionSubclassForInheritanceMapping();
      }
  }
  
  public class PoweredVehicleMap : SubclassMap&lt;PoweredVehicle&gt;
  {
      public PoweredVehicleMap()
      {
          Map(x =&gt; x.EngineType);
          Abstract();
      }
  }
  
  public class CarMap : SubclassMap&lt;Car&gt;
  {
      public CarMap()
      {
          Map(x =&gt; x.Doors);
      }
  }
  
  public class TruckMap : SubclassMap&lt;Truck&gt;
  {
      public TruckMap()
      {
          Map(x =&gt; x.MaxLoad);
      }
  }
  
  public class BicycleMap : SubclassMap&lt;Bicycle&gt;
  {
      public BicycleMap()
      {
          Map(x =&gt; x.FrameSize);
      }
  }
  </code></pre>
  
  <p>I insert a Car and a Bicycle. When I try to insert an Owner with a list of Vehicle objects (with a Car and a Bicycle), I get the following error:</p>
  
  <blockquote>
    <p>Exception: NHibernate.Exceptions.GenericADOException: could not insert
    collection:
    [NHibernateTest.Owner.Vehicles#8ace95bc-ad80-46d7-94c7-a11f012b67c6][SQL:
    UPDATE "Vehicle" SET Owner_id = @p0 WHERE Id = @p1] --->
    System.Data.SQLite.SQLiteException: SQLite error</p>
  </blockquote>
  
  <p>Since I setup table per concrete class, why is NHibernate trying to update a non-existing table, which is representing the base class? Is this type of mapping not supported for this scenario?</p>
  
  <p>Also, when I change from HasMany to HasManyToMany, this works fine.</p>