Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 571

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Advanced mapping
Collection Mapping
Collection mapping is similar to a one-to-many relationship mapping. However, in collection mapping, you have a
collection of values instead of a collection of persistent target objects.
Consider the Artist-Art tables. If you want each Artist object to contain an array of artwork names instead of artwork
objects, collection mapping should be used.
To define collection mapping in the CFC, use
The collection can either be
Array
Syntax
name="field_name"
fieldtype="collection"
type="array"
table="table_name"
fkcolumn="foreign_key_column_name"
elementtype="ormtype"
elementColumn="column_name from the link table that should be
used for populating"
orderby="order by string"
lazy = "true|[false]"
readonly="true|[false]"
optimisticlock="[true]|false"
batchsize="batch size">
Example
If each Artist object contains an array of artwork names instead of artwork objects, this mapping can be defined in
Artist.cfc as:
<cfproperty name="artNames" fieldtype="collection" type="array" table="ART"
fkcolumn="ARTISTID" elementcolumn="ARTNAME" elementtype="string">
Attribute
Attribute
Req/Opt
batchsize
Optional
elementColumn
Required
elementtype
Optional
fieldtype
Required
fieldtype="collection"
or
.
Array
Struct
Default
String
Last updated 1/20/2012
in the
tag.
cfproperty
Description
An integer value that specifies the
"
batchsize
" for fetching uninitialized
collections. For details, see
Specifies the column name that contains
the data to be fetched for collection.
Data type of the selected column. See
data types
for details.
Should be "collection".
566
Lazy
Loading.
ORM

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents