Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 395
Daniel T. Avatar asked Aug 09 '11 06:08

Daniel T.


1 Answers

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.

like image 196
CfSimplicity Avatar answered Sep 27 '22 16:09

CfSimplicity