Orm Coldfusion形成一对一的多条件关系

Orm Coldfusion形成一对一的多条件关系,orm,coldfusion,coldfusion-9,one-to-one,Orm,Coldfusion,Coldfusion 9,One To One,在我们的cms中,我们有一个用于跟踪所有对象的表。它接受来自不同对象(图像、视频、帖子、文章等)的记录id,并根据对象类型映射它们 我们正在升级我们的很多系统以使用ORM,因此我现在需要将对象之间的关系映射到它们的对象记录。(在下面的示例中,我需要将对象属性映射到图像组件) 所以 我不知道如何设置这种一对一的关系,因为它不是主键对主键。而且它也不是唯一的外键关联,因为它是一个多列唯一性约束 这不是coldfusion此时可以处理的吗?为了避免使用主对象ID作为键,请尝试使用Image.cfc中的

在我们的cms中,我们有一个用于跟踪所有对象的表。它接受来自不同对象(图像、视频、帖子、文章等)的记录id,并根据对象类型映射它们

我们正在升级我们的很多系统以使用ORM,因此我现在需要将对象之间的关系映射到它们的对象记录。(在下面的示例中,我需要将对象属性映射到图像组件)

所以

我不知道如何设置这种一对一的关系,因为它不是主键对主键。而且它也不是唯一的外键关联,因为它是一个多列唯一性约束


这不是coldfusion此时可以处理的吗?

为了避免使用主对象ID作为键,请尝试使用Image.cfc中的
mappedBy
属性将图像对象连接到您添加的具有双向关系的ImageObject子类,如下所示:

Object.cfc(父级)


ImageObject.cfc(子对象)


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

我认为“鉴别器”可能是用于此目的的,请看,我已经对此进行了尝试,并成功地使用鉴别器将对象类扩展到imageObject。但这打乱了所有对象的关系,因为它们仍然使用不需要鉴别器的主ID连接到主对象,因此这些关系因失去鉴别器而痛苦不堪。。。如果这有任何意义的话。
object.recordID = image.ID where classID = 'image'
<cfcomponent name="Object" persistent="true" accessors="true" table="objects" discriminatorColumn="classID">

    <cfproperty name="id" fieldtype="id" generator="identity" column="ID">

</cfcomponent>
<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>
<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>