NHibernate的。混合继承策略

时间:2013-02-27 19:14:30

标签: nhibernate inheritance mapping

我想实现这个层次结构:

BaseOrder --> Order --> ConstOrder

我的映射: BaseOrder.hbm

<class name="BaseOrder, BackOffice.Core" abstract="true">
    <id name="Id" unsaved-value="0" type="int">
      <column name="id" not-null="true"/>
      <generator class="hilo">
        <param name="max_lo">0</param>
        <param name="where">table_name = 'orders'</param>
      </generator>
    </id>

</class>

Order.hbm

<union-subclass name="Order, Transport.Core" table="order" extends="BaseOrder, BackOffice.Core">
  <property name="PeopleNum">
    <column name="people_num" length="64"/>
  </property>      
</union-subclass>

ConstOrder.hbm

 <joined-subclass name="ConstOrder, Transport.Core" table="const_order" extends="Order, Transport.Core">
      <key column="Id"/>
      <property name="PeriodType">
        <column name="period_type"/>
      </property>
    </joined-subclass>

确定。我从每个具体类的Table开始,并以每个子类的Table结束。 我遇到了一些问题:

ICriteria criteria = session.CreateCriteria(typeof(ConstOrder));
return criteria.List<ConstOrder>() as List<ConstOrder>;

我的继承映射是否可行?我怎样才能获得Constorders?

1 个答案:

答案 0 :(得分:0)

NH不支持mixin继承策略。