gpt4 book ai didi

java - 使用子类时拆分 Hibernate 配置文件(hbm.xml 文件)

转载 作者:行者123 更新时间:2023-12-04 06:14:29 26 4
gpt4 key购买 nike

我们有一个 hibernate 映射文件(hbm.xml 文件),它将我们域的一部分映射到数据库。这部分包含一个继承层次结构。 IE。我们有一个父类“Parent”和几个子类“Child1”、“Child2”……

由于 hibernate 映射文件的结构,子类位于父类中 <class> XML 标记为 <joined-subclass> .

由于这个映射文件变得越来越大,我们现在要拆分它。有没有办法为每个子类创建一个映射文件?

最佳答案

新 XML 中的标记:

<joined-subclass />

或者
<hibernate-mapping>
<subclass name="DomesticCat" extends="Cat" discriminator-value="D">
<property name="name" type="string"/>
</subclass>
</hibernate-mapping>

从 hibernate 站点中提取:
It is possible to define subclass, union-subclass, and joined-subclass mappings in separate mapping documents directly.

引用: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html

你做

关于java - 使用子类时拆分 Hibernate 配置文件(hbm.xml 文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7427874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com