读书人

inheritance 地图ping

发布时间: 2012-10-07 17:28:51 作者: rapoo

inheritance mapping
the three strategies:
table per class hierarchytable per subclasstable per concrete class

1.Table per class hierarchy
Suppose we have an interface Payment with the implementors CreditCardPayment and CashPayment. The table per class hierarchy mapping would display in the following way:

<class name="Payment" table="PAYMENT"><id name="id" type="long" column="PAYMENT_ID"><generator type="string"/><property name="amount" column="AMOUNT"/>...<subclass name="CreditCardPayment" discriminator-value="CREDIT"><property name="creditCardType" column="CCTYPE"/>...</subclass><subclass name="CashPayment" discriminator-value="CASH">...</subclass></class>

Exactly one table is required. There is one limitation of this mapping:columns declared by the subclass cannot have not null constraints.

读书人网 >软件架构设计

热点推荐