title: NHibernate: Map same class to multiple tables depending on parent
body: <p>I have a model where multiple classes have a list of value types:</p>
  
  <pre><code>class Foo { public List&lt;ValType&gt; Vals; }
  class Bar { public List&lt;ValType&gt; Vals; }
  </code></pre>
  
  <p>Foo and Bar are unrelated apart from that they both contain these vals. The rules for adding, removing, etc. the ValTypes are different for each class. I'd like to keep this design in my code. </p>
  
  <p>There are times when I want to copy some Vals from a Foo to a Bar, for example.  In the database, each ValType has its own table, to keep it small, light (it just has the parent ID + 2 fields), and allow integrity checks. I know NHibernate says I should keep my objects as granular as the database, but that just makes my code uglier.</p>
  
  <p>The best I've thought of so far is to make separate subclasses of ValType, one for each parent. Then I can map those at that level. Then, I'll hook up add and remove logic to auto-convert between the right subclasses, and actually store them in a private list that has the right subclass type. But this seemed a bit convoluted.</p>
  
  <p>How can I map this in NHibernate (Fluent NHibernate if possible)?</p>
  
  <p>Please let me know if this is a duplicate -- I'm not quite sure how to search this.</p>