[英]How do you map a base class using ColdFusion ORM?
I have two components, a base Entity
component: 我有两个组件,一个基本的
Entity
组件:
<cfcomponent persistent="true">
<cfproperty name="Id" fieldtype="id" generator="native">
</cfcomponent>
And a Client
component that extends it: 还有一个扩展它的
Client
组件:
<cfcomponent persistent="true" extends="Entity">
<cfproperty name="FirstName">
<cfproperty name="LastName">
</cfcomponent>
However, when I try to create an instance of Client
, I get an error that says that they're being mapped as two different tables. 但是,当我尝试创建
Client
的实例时,出现一个错误,指出它们被映射为两个不同的表。 I know Hibernate has the ability to ignore a base class, but how would I do it with ColdFusion's tags, or do I have to fall back to HBM mappings for this feature? 我知道Hibernate可以忽略基类,但是我该如何使用ColdFusion的标签,还是必须依靠HBM映射才能使用此功能?
Addendum: Removing the persistent="true"
from Entity
doesn't work either, Client
will act as if it doesn't have an Id
property if I do so. 附录:从
Entity
删除persistent="true"
也不起作用,如果我这样做, Client
将表现为没有Id
属性。
In your base "Entity" class try removing persistent="true" and adding mappedSuperClass="true". 在您的基本“ Entity”类中,尝试删除persistent =“ true”并添加mappedSuperClass =“ true”。
<cfcomponent mappedSuperClass="true">
<cfproperty name="Id" fieldtype="id" generator="native">
</cfcomponent>
You need to have applied the 9.0.1 update to ColdFusion. 您需要将9.0.1更新应用到ColdFusion。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.