如何使用 ColdFusion ORM 映射基类? [英] How do you map a base class using ColdFusion ORM?

查看:24
本文介绍了如何使用 ColdFusion ORM 映射基类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组件,一个基础 Entity 组件:

I have two components, a base Entity component:

<cfcomponent persistent="true">
    <cfproperty name="Id" fieldtype="id" generator="native">
</cfcomponent>

还有一个扩展它的 Client 组件:

And a Client component that extends it:

<cfcomponent persistent="true" extends="Entity">
    <cfproperty name="FirstName">
    <cfproperty name="LastName">
</cfcomponent>

但是,当我尝试创建 Client 的实例时,我收到一条错误消息,指出它们被映射为两个不同的表.我知道 Hibernate 具有忽略基类的能力,但是我将如何使用 ColdFusion 的标签来做到这一点,或者我是否必须回退到 HBM 映射来实现此功能?

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. 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?

附录:从 Entity 中删除 persistent="true" 也不起作用,Client 将表现得好像没有如果我这样做,有一个 Id 属性.

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" 并添加 mappedSuperClass="true".

In your base "Entity" class try removing persistent="true" and adding mappedSuperClass="true".

<cfcomponent mappedSuperClass="true">
    <cfproperty name="Id" fieldtype="id" generator="native">
</cfcomponent>

您需要将 9.0.1 更新应用到 ColdFusion.

You need to have applied the 9.0.1 update to ColdFusion.

这篇关于如何使用 ColdFusion ORM 映射基类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆