企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 9.1.4\. 混合使用“每个类分层结构一张表”和“每个子类一张表” 你甚至可以采取如下方法混和使用“每个类分层结构一张表”和“每个子类一张表”这两种策略: ``` <class name="Payment" table="PAYMENT"> <id name="id" type="long" column="PAYMENT_ID"> <generator class="native"/> </id> <discriminator column="PAYMENT_TYPE" type="string"/> <property name="amount" column="AMOUNT"/> ... <subclass name="CreditCardPayment" discriminator-value="CREDIT"> <join table="CREDIT_PAYMENT"> <property name="creditCardType" column="CCTYPE"/> ... </join> </subclass> <subclass name="CashPayment" discriminator-value="CASH"> ... </subclass> <subclass name="ChequePayment" discriminator-value="CHEQUE"> ... </subclass> </class> ``` 对上述任何一种映射策略而言,指向根类`Payment`的 关联是使用`&lt;many-to-one&gt;`进行映射的。 ``` <many-to-one name="payment" column="PAYMENT_ID" class="Payment"/> ```