Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 566

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
<cfproperty
name="fieldname"
fieldtype="one-to-one"
cfc="Referenced_CFC_Name"
linktable="Link table name"
linkcatalog="Catalog for the link table"
linkschema="Schema for the link table"
fkcolumn="Foreign Key column name"
inversejoincolumn="Column name or comma-separated list of primary key columns"
mappedby="Mapped_Field_name_in_referenced_CFC"
cascade="none"
fetch="join|[select]"
lazy="[true]|false">
Note: The mappedby attribute can not be specified with the fkcolumn attribute.
Example
In the EMPLOYEE and OFFICECUBICLE example, OFFICECUBICLE has a foreign key column, EMPLOYEEID.
This foreign key references the primary key of the Employee table. OFFICECUBICLE has an auto-generated primary
key, which does not participate in the relationship.
EMPLOYEE.cfc
<cfcomponent persistent="true" table="Employee">
<cfproperty name="EmployeeID" fieldtype="id" generator="native">
<cfproperty name="firstname">
<cfproperty name="lastname">
<cfproperty name="officecubicle" fieldtype="one-to-one" cfc="officecubicle"
mappedby="Employee">
</cfcomponent>
OFFICECUBICLE.cfc
<cfcomponent persistent="true" table="officecubicle">
<cfproperty name="id" fieldtype="id" generator="native">
<cfproperty name="Employee" fieldtype="one-to-one" cfc="Employee" fkcolumn="EmployeeID">
<cfproperty name="Location">
<cfproperty name="Size">
</cfcomponent>
• In OFFICECUBICLE entity,
OFFICECUBICLE table.
specifies that the one-to-one relationship is with the foreign-key property 'EMPLOYEE' in
mappedby="Employee"
OFFICECUBICLE entity and not with its primary key.
• In Employee entity, fkcolumn should not be specified.
In this case, OFFICECUBICLE entity has a independent Primary key which is auto-generated.
One-to-many relationship
A one-to-many relationship is where the source object has field that stores a collection of target objects. These target
objects may also have an inverse relationship back to the source object. This relationship is established by having a
foreign key in the target table that maps to the primary key of the source table.
An example of a one-to-many relationship is the relation between artist and art, where the artist has many artwork
pieces.
specifies that EmployeeID is the foreign key column in
fkcolumn="EmployeeID"
Last updated 1/20/2012
561

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents