0
我想實現這個層次:NHibernate。混合繼承策略
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?