当我运行下面的代码时,ColdFusion 9(更新为最新版本)为计费地址cfc生成一个错误的(imho) XML文件。也就是说,它包含了base.cfc的性质。这是一个错误,我是遗漏了什么,还是这是预期的行为?
Application.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";
}address.cfc
component extends = "model.base"
persistent = "true"
table="address"
discriminatorColumn = "discriminator"
{
property name = "address";
}billingaddress.cfc
component extends = "model.address"
persistent = "true"
table="address"
discriminatorValue = "billingaddress"
{}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>发布于 2014-09-29 21:43:12
这就是我所期望的行为。扩展组件将导致子组件继承父组件的属性。当您有多个继承级别时,它将继承整个链。
在阅读了你的评论后,我进一步研究了这一点。据我所知,您首先描述的问题出现在CF9累积热修正2中,可能(只是在这里猜测),这是错误修复的结果:
当ColdFusion扩展属性mappedSuperclass设置为true的基CFC时,mappedSuperclass ORM不能正确地维护列顺序。
所引用的bug是#83474,我似乎无法在Adobe的bug跟踪器上找到它。它反映在埃利奥特·斯普雷恩的网站这里上。
我在这里还发现了另一个关于同样问题的问题:在ColdFusion 9.0.1修补程序2的继承图中使用映射的超类时,HBM映射错误。该问题中报告的解决方法是手动编辑hbmxml文件。
长话短说,它看起来像个CF虫。我戳了它大约20分钟,除了手动编辑hbmxml文件从billingaddress.cfc中删除额外的属性之外,找不到其他的解决办法。
https://stackoverflow.com/questions/26109254
复制相似问题