Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, there are a number of options you can use to do what you want. Ayende Rahien has a <a href="http://nhforge.org/blogs/nhibernate/archive/2009/04/10/nhibernate-mapping-inheritance.aspx" rel="nofollow noreferrer">great demonstration of the options</a> for table inheritance and the resulting table structures. </p> <p>Using the class hierarchy that has an abstract BaseOrder as a parent to CompleteOrder and IncompleteOrder, the union case is:</p> <pre><code>&lt;class name="CompleteOrder" table="CompleteOrders"&gt; &lt;id name="Id"&gt; &lt;generator class="identity"/&gt; &lt;/id&gt; &lt;property name="Status"/&gt; &lt;/class&gt; &lt;class name="IncompleteOrder" table="IncompleteOrders"&gt; &lt;id name="Id"&gt; &lt;generator class="identity"/&gt; &lt;/id&gt; &lt;/class&gt; </code></pre> <p>or</p> <pre><code> &lt;class name="BaseOrder" abstract="true" table="Orders"&gt; &lt;id name="Id"&gt; &lt;generator class="hilo"/&gt; &lt;/id&gt; &lt;union-subclass table="CompleteOrders" name="CompleteOrder"&gt; &lt;property name="Status"/&gt; &lt;/union-subclass&gt; &lt;union-subclass table="IncompleteOrders" name="IncompleteOrder"&gt; &lt;/union-subclass&gt; &lt;/class&gt; </code></pre> <p>which also has separate tables but doesn't use a union for the query. </p> <p>Check out the <a href="http://nhforge.org/blogs/nhibernate/archive/2009/04/10/nhibernate-mapping-inheritance.aspx" rel="nofollow noreferrer">article</a>, it will probably help greatly.</p> <hr> <p><strong>edit:</strong></p> <p>There was a comment about not wanting to cast but it's now gone. I'm not sure if it was deleted or if it was a SO issue...</p> <p>If BaseOrder.Status is a virtual property, you should be able to pass around a BaseOrder and not need to cast. You'll have to maintain the extra class hierarchy but you can still query them together and, for the most part, the rest of the application shouldn't need to know about the subclasses. </p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload