
551
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
Computed property
Computed property is a property whose value does not come from a column but is computed using a SQL query. Use
formula attribute to specify the SQL to be used to retrieve the value for this property.
<cfcomponent persistent="true" table="ARTISTS" schema="APP">
<cfproperty name="ID" column="ARTISTID" fieldtype="id"/>
<cfproperty name="FIRSTNAME"/>
<cfproperty name="LASTNAME"/>
<cfproperty name="NumberOfArts" formula="select count(*) from Art art where
art.ArtistID=ArtistID"/>
</cfcomponent>
Versioning
Versioning is a technique that allows you to implement concurrency control fora component. You can specify either
version
or
timestamp
property for a component.
For details, see
Optimistic locking
.
Note:
A component can have only one versioning property, either timestamp or version. If you specify multiple versioning
properties, such as two timestamps, or two versions, or a timestamp and a version, an error is thrown.
Version
Use the version attribute to indicate that the column contains versioned data. The version attribute is useful for long
transactions.
Attribute
Req/Opt
Default
Description
dbdefault
optional
Specifies the default value of the column in the table.
index
optional
Specifies the name of an index that is created using the mapped
column.
length
optional
Specifies the length value.
notnull
optional
false
A Boolean value that specifies whether a notnull constraint should
be added for this column.
precision
optional
Specifies the precision value.
scale
optional
Specifies the scale value.
sqltype
optional
This allows user to override the default mapping of
ormtype
to SQL
datatype.
sqltype
is used as the DB specific SQL type for a column
when creating the table. If this attribute is not specified, ColdFusion
will automatically decide the
sqltype
based on the
ormtype
specified for this property.
For example:
<cfProperty name="active" ormtype="char"
sqltype="bit">
<cfProperty name="balance" ormtype="float"
sqltype="decimal(13,3)">
unique
optional
Specifies if there should be a unique constraint on the column.
uniquekey
optional
Groups columns in a single unique key constraint.