gpt4 book ai didi

hibernate - ColdFusion ORMmappedSuperClass.hbmxml 有太多字段

转载 作者:行者123 更新时间:2023-12-02 22:43:31 25 4
gpt4 key购买 nike

当我运行下面的代码时,ColdFusion 9(更新到最新)为 billingaddress cfc 生成错误的(恕我直言)XML 文件。即,它包括base.cfc的属性。这是一个错误,我错过了什么,还是这是预期的行为?

应用程序.cfc

component
{
this.name = "ormtest";
this.mappings["/model"] = expandPath( "./model" );
this.datasource = "mingo";
this.ormEnabled = true;
this.ormSettings = {
CFCLocation = "/model",
dbcreate = "dropcreate",
savemapping = true
};

function onRequestStart()
{
ormreload();
}
}

base.cfc

component mappedSuperClass = "true"
{
property fieldType = "id" name = "id" generator = "guid";
property fieldType = "column" name = "deleted" ORMType = "boolean" default = "0" notnull = "true";
property fieldType = "column" name = "sortorder" ORMType = "integer";
property fieldType = "column" name = "label";
}

地址.cfc

component extends = "model.base"
persistent = "true"
table="address"
discriminatorColumn = "discriminator"
{
property name = "address";
}

账单地址.cfc

component extends = "model.address"
persistent = "true"
table="address"
discriminatorValue = "billingaddress"
{}

账单地址.hbmxml

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<subclass discriminator-value="billingaddress"
entity-name="billingaddress" extends="cfc:model.address"
lazy="true" name="cfc:model.billingaddress">
<property name="deleted" type="boolean">
<column name="deleted" not-null="true"/>
</property>
<property name="sortorder" type="integer">
<column name="sortorder"/>
</property>
<property name="label" type="string">
<column name="label"/>
</property>
</subclass>
</hibernate-mapping>

最佳答案

这就是我所期望的行为。扩展组件将导致子组件继承父组件的属性。当您有多个继承级别时,它将一路继承到链上。

阅读您的评论后,我进一步研究了这一点。据我所知,您描述的问题首先出现在CF9 Cumulative Hot Fix 2中,可能(只是在这里猜测)由于此错误修复:

ColdFusion ORM does not maintain the column order correctly when the CFC extends a base cfc with an attribute mappedSuperclass set to true.

引用的错误是#83474,我似乎无法在 Adob​​e 的错误跟踪器上找到它。它反射(reflect)在 Elliot Sprehn 的网站上,here .

我还在这里找到了关于同一问题的另一个问题:Wrong HBM mappings when using a mapped superclass in an inheritance graph for ColdFusion 9.0.1 Hotfix 2 。该问题中报告的解决方法是手动编辑 hbmxml 文件。

长话短说,它看起来像是一个 CF bug。我研究了大约 20 分钟,除了手动编辑 hbmxml 文件以删除 billingaddress.cfc 中的额外属性之外,无法找到解决方法。

关于hibernate - ColdFusion ORMmappedSuperClass.hbmxml 有太多字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26109254/

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