
546
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
Primary key
Simple primary key
In a relational database, a primary key is defined as a key that uniquely identifies a row in a table. Typically, a table has
one primary key that represents a single column of information in the table.
To indicate that a
cfproperty
maps to a primary key in the table, set the attribute
fieldtype="id"
.
Attribute
Req/Optional
Default
Description
default
optional
This sets the default value on the property when the object is
created.
fieldtype
optional
column
This attribute is used to specify the type of the property. Use this
attribute to specify the following:
•
Primary key: Specify
fieldtype = "id"
to map a property to
the primary key in the table. For details, see
Primary key
.
•
Column: Specify the
fieldtype = "column"
to map a
property to a column in the table. For details, see
Column
.
•
Relationship: Specify the
fieldtype =
"
relationship_type
"
. The
relationship_type
can be
one-
to-one
,
one-to-many
,
many-to-one
, or
many-to-many
. For
details, see
Define Relationships
.
•
Version: Specify the
fieldtype="version
” to indicate that
the column contains versioned data. For details, see
Version
.
•
Timestamp: Specify the
fieldtype="timestamp"
to indicate
the column contains data with timestamp. For details, see
Time
stamp
.
•
Collection: Specify the
fieldtype="collection"
to define
the collection mapping. For details, see
Collection Mapping
name
required
Specifies the name of the property.
type
optional
Specifies the ColdFusion data type for the property.
persistent
optional
true
Specifies whether this property should be persisted. If
persistent="false
” all the ORM related attributes are ignored.
Set this attribute to false if you do not want this property to be
persisted by ORM. For example:
<cfcomponent persistent=true>
<cfproperty name="a">
<cfproperty name="b" persistent="true">
<cfproperty name="c" persistent="false">
</cfcomponent>
When an object of this CFC is persisted, the properties a and b
would be persisted in the database but the property c would not
be persisted.
remotingFetc
h
optional
true
If
remotingFetch
is
false
, then the value of that attribute is not
sent over flash remoting. The attribute is true by default for all
properties. However, for ORM CFCs where persistent = true, the
value of the
remotingFetch
attribute is set to false, by default,
for one-to-one, one-to-many, many-to-one, or many-to-many
relationships.