Adobe COLDFUSION 9 Manual page 564

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
You can also specify comma separated cascade values in the
relationship, the most common values are all-delete-orphan.
For an association where the child object can continue to exist even if the parent object is deleted, you can apply the
save-update cascade value.
Applying filter on associated objects
In one-to-many and many-to-many relationships, an array or struct is retrieved. Filters can be applied to retrieve a
subset of the associated objects. The filter can be specified in the
one-to-many association for artist and artwork:
If you want to retrieve only the unsold artwork for every Artist object, you need to define the mapping as follows:
<cfproperty name="unsoldArts" cfc="Art" fieldtype="one-to-many" fkcolumn="ARTISTID"
where="issold=0">
Inverse
In a bidirectional relationship, the
query should be executed for the association, when persisting the object.
Consider the ART and ARTIST CFCs, which have a bidirectional one-to-many relationship. This means that each ART
object has a reference to the ARTIST object and ARTIST object has a reference to the ART object. While persisting
ARTIST and the associated ART, the relationship can be established in the database from both sides of the object.
Setting
on one side of the relation tells ORM to ignore this side of relation for executing the SQL.
inverse=true
As a general rule, in a bidirectional relation, one side must set
relation,
should be set on the many side of the relation. For example, in ARTIST-ART relation, inverse should
inverse
be set to
on the '
' property in ARTIST.
true
art
In many-to-many relation, you can set
One-to-one relationships
A one-to-one relationship is where the source object has an attribute that references another single target object and
vice-versa. An example of this relationship is the relationship between an employee and the assigned office cubicle,
where one employee has one office cubicle and one office cubicle belongs to only one employee.
A one-to-one relationship between two persistent components are defined using
Syntax:
<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"
cascade="cascade_options"
constrained="true|[false]"
fetch="join|[select]"
lazy="[true]|false">
There are two types of one-to-one relationships:
• Primary key association
cascade
attribute is used on an association property to specify whether an SQL
inverse
inverse
on any side of the relation.
inverse=true
Last updated 8/5/2010
attribute. For a one-to-one or a one-to-many
attribute, which is an SQL where clause. In a
where
to
. For one-to-many or many-to-one
true
fieldtype
559
value one-to-one.

Advertisement

Table of Contents
loading

Table of Contents