inheritance mapping
程序员文章站
2022-07-15 13:12:58
...
the three strategies:
[list]
[*]table per class hierarchy
[*]table per subclass
[*]table per concrete class
[/list]
[b]1.Table per class hierarchy[/b]
Suppose we have an interface Payment with the implementors CreditCardPayment and CashPayment. The table per class hierarchy mapping would display in the following way:
Exactly one table is required. There is one limitation of this mapping:columns declared by the subclass cannot have [i]not null [/i]constraints.
[list]
[*]table per class hierarchy
[*]table per subclass
[*]table per concrete class
[/list]
[b]1.Table per class hierarchy[/b]
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 class="native"/>
</id>
<discriminator column="PAYMENT_TYPE" 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 [i]not null [/i]constraints.
上一篇: 'org.mybatis.spring.mapper.MapperScannerConfigurer' to required type 'xxx' for property 'XX'
下一篇: Mapping Cipher
推荐阅读
-
详解 hibernate mapping配置
-
C++ Notes-Inheritance-06
-
ElasticStack学习(七):ElasticSearch之Mapping初探
-
Mybatis映射赋值失败;异常:TypeException: Could not set parameters for mapping
-
详解 hibernate mapping配置
-
【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user
-
Hibernate 中的 idclass mapping 问题
-
ES 11 - 配置Elasticsearch的映射(mapping)
-
mybatis-generator自动生成dao、mapping、bean配置操作
-
HibernateTools实现pojo类 数据库schma mapping映射的相互转换