mappedBy
为避免使用主对象 ID 作为键,请尝试使用 Image.cfc 中的属性将 Image 对象连接到您添加的具有双向关系的 ImageObject 子类,如下所示:
Object.cfc(父)
<cfcomponent name="Object" persistent="true" accessors="true" table="objects" discriminatorColumn="classID">
<cfproperty name="id" fieldtype="id" generator="identity" column="ID">
</cfcomponent>
ImageObject.cfc(儿童)
<cfcomponent name="ImageObject" persistent="true" accessors="true" extends="Object" table="objects" discriminatorValue="image">
<!--- Connect to the image using the foreign key --->
<cfproperty name="image" fieldtype="one-to-one" cfc="Image" fkcolumn="recordID">
</cfcomponent>
图像.cfc
<cfcomponent name="Image" persistent="true" accessors="true" table="images">
<cfproperty name="id" fieldtype="id" generator="identity" column="ID">
<!--- Connect to the ImageObject using the relationship already defined in ImageObject--->
<cfproperty name="objectRecord" fieldtype="one-to-one" cfc="ImageObject" mappedby="image">
</cfcomponent>