I'm working on a parent/sub application structure in CFML (Railo) and I'm struggling with extending my persistent (ORM) CFCs.
What I'd like is for my persistent CFCs to live in the parent application. They would contain the various properties, and a few functions dealing with core functionality.
In my sub app, I would like to extend the ORM CFCs declaring any sub app specific properties, and I would like to be able to add new functions specific to the needs of the sub app, as well as overriding any of the core functions if required, without touching the code in the parent app's CFCs.
The sub app uses its own datasource, so I'd expect to see the ORM tables generated in the sub's database on application start. If I start the parent app (which runs standalone and has its own datasource) I can see the tables generated there without issue. If I start the child app however, the tables are not generated (in either database).
I've tried adding mappedSuperclass='true' to the parent CFCs and creating CFCs in the child app that extend the parent CFCs.
I've also tried adding the parent app's ORM folder to the array of CFCLocation folders in the ORM settings.
The only thing I'm able to use as an indication that the ORM is working, is to see whether the tables are generated in the database. If there's another way I can see if the ORM CFCs are working, I'd love to hear about it!
Here's some code to look at:
Parent image.cfc
<cfcomponent persistent="true" entityname="Image" table="tblImages_Base" extends="com.orm.SimpleBasePersistentObject" mappedSuperClass="true">
<!--- Identifier --->
<cfproperty name="sImageUUID" fieldtype="id" generator="assigned" setter="false" />
<!--- Properties --->
<cfproperty name="dtDateCreated" ormtype="timestamp" setter="false" />
<cfproperty name="dtLastUpdated" ormtype="timestamp" setter="false" />
<cfproperty name="sFileName" ormtype="string" />
<cfproperty name="iFileSize" ormtype="int" default="0" dbdefault="0" />
<cfproperty name="iWidth" ormtype="int" default="0" dbdefault="0" />
<cfproperty name="iHeight" ormtype="int" default="0" dbdefault="0" />
<cfproperty name="sImageFolder" ormtype="string" dbdefault="" />
<cfproperty name="Active" ormtype="boolean" default="0" dbdefault="0" notnull="true" />
<!--- Non persistant properties --->
<cfproperty name="sImagePath" type="string" persistent="false" />
<cfproperty name="sDefaultImageLocation" persistent="false" />
<!--- Many Images can have one image type --->
<cfproperty name="ImageType"
fieldtype="many-to-one"
cfc="ImageType"
fkcolumn="fk_sImageType"
fetch="join"
/>
</cfproperty>
</cfcomponent>
Sub image.cfc
<cfcomponent persistent="true" entityname="Image" table="tblImages_Base" extends="core.orm.Image">
</cfcomponent>