简体   繁体   中英

How do you map a base class using ColdFusion ORM?

I have two components, a base Entity component:

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

And a Client component that extends it:

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

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.

In your base "Entity" class try removing persistent="true" and adding 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM