cfproperty

Defines properties of a CFML component (CFC). Used to
create complex data types for web services. The attributes of
this tag are exposed as component metadata and are subject to
inheritance rules.

  <cfproperty name="">

Attribute Reference

name string
Required

Specifies the name of the property.

type string

Specifies the ColdFusion data type for the property.
Values:
  • any
  • array
  • binary
  • boolean
  • date
  • guid
  • numeric
  • query
  • string
  • struct
  • uuid
  • variablename

required boolean

Whether the parameter is required

default string

This sets the default value on the property when the object is created. For ORM Entities, this only works for static values. Variable values like the current timestamp can be set by a function "preInsert" in the component.

displayname string

A value to be displayed when using introspection to show
information about the CFC. The value appears in parentheses
following the property name.

hint string

Text to be displayed when using introspection to show
information about the CFC. This attribute can be useful
for describing the purpose of the parameter.

fieldtype string

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.
* Column: Specify the fieldtype = "column" to map a property to a column in the table.
* Relationship: Specify the fieldtype = "relationship_type". The relationship_type can be one-to-one, one-to-many, many-to-one, or many-to-many.
* Version: Specify the fieldtype="version” to indicate that the column contains versioned data.
* Timestamp: Specify the fieldtype="timestamp" to indicate the column contains data with timestamp.
* Collection: Specify the fieldtype="collection" to define the collection mapping.
Values:
  • id
  • column
  • one-to-one
  • one-to-many
  • many-to-many
  • many-to-one
  • collection
  • timestamp
  • version

ormType string

Used to specify the data type of the primary key. If data type is not set and the ORM setting
useDBForMapping=true, then the ormtype is determined by inspecting the database.
Values:
  • string
  • character
  • char
  • short
  • integer
  • int
  • long
  • big_decimal
  • float
  • double
  • boolean
  • yes_no
  • true_false
  • text
  • date
  • timestamp
  • binary
  • serializable
  • blob
  • clob

column string

Used to specify the primary key column name.

generator string

Algorithm used to generate unique identifiers for instances of the persistent CFC.
Values:
  • increment
  • identity
  • sequence
  • seqhilo
  • uuid
  • guid
  • native
  • assigned
  • select
  • foreign
  • sequence-indentity

sequence string

Sequence key name in the database.

selectkey string

The column name that is used to retrieve the primary key generated by a database trigger.

params string

Additional parameters required by the various generators to generate the ID.
The value for the params attribute should follow the CF Struct syntax. For example: params = {key1='value1', key2='value2'}

length string

Use this attribute to specify the length of the column. This attribute is used for table creation only.

precision string

Specifies the precision value.

index string

Specifies the name of an index that is created using the mapped column

setter boolean

Specifies whether to generate setter methods or not

getter boolean

Specifies whether to generate getter methods or not

source string
Default: vm

Specifies the source from where the timestamp has to be retrieved
Values:
  • vm
  • db

elementcolumn string

Column name in the table that is used as value in struct.

elementtype string

Data type of the value.
Values:
  • string
  • character
  • char
  • short
  • integer
  • int
  • long
  • big_decimal
  • float
  • double
  • boolean
  • yes_no
  • true_false
  • text
  • date
  • timestamp
  • binary
  • serializable
  • blob
  • clob

structkeytype string

Specifies the data type of the key, when collectiontype=struct.
Values:
  • string
  • character
  • char
  • short
  • integer
  • int
  • long
  • big_decimal
  • float
  • double
  • boolean
  • yes_no
  • true_false
  • text
  • date
  • timestamp
  • binary
  • serializable
  • blob
  • clob

structkeycolumn string

The column in the target table to use as key if the collection type is struct.

inversejoincolumn string

Specifies the foreign key column in the Join table that references the primary key column in the target table.

linkschema string

Schema for the link table

linkcatalog string

Catalog for the link table

linktable string

Name of the link table

missingRowIgnored boolean

If the value is true, and the row that is referenced by the foreign key is missing, it is treated as a null
association. The default is false, in which case an exception occurs.

inverse boolean

A Boolean value that specifies bidirectional association

orderby string

Specifies the Order By string.

fkcolumn string

Specifies the foreign key column

fetch string

Specifies if it is outer-join fetching or sequential select fetching
Values:
  • join
  • select

cascade string

Specifies which operations should be cascaded from the parent object to the associated object
Values:
  • all
  • none
  • save-update
  • delete
  • all-delete-orphan
  • delete-orphan
  • create
  • merge
  • lock
  • refresh
  • evict
  • replicate

constrained boolean

Whether a constraint is set on this table's Primary Key column to reference the Primary Key in the other table

unique boolean

Specifies if there should be a unique constraint on the column.
Values:
  • false
  • true

uniquekey string

Groups columns in a single unique key constraint.

notnull boolean

A Boolean value that specifies whether a notnull constraint should be added for this column.

update string

Whether the column should be included in the SQL update statement.
Set update=false and insert=false if the column needs to be read-only.

insert boolean

Whether the column should be included in SQL UPDATE and/or INSERT statements.
Set update=false and insert=false if the column needs to be read-only.

generated string

Specifies that this property value is actually generated by the database {never|always|insert}
* never: Specifies that the value for this property is never generated by database
* always: Specifies that the value for this property is always generated by database
* insert: Specifies that the value for this property is generated at the time of insert but is not regenerated at updates.
Values:
  • never
  • insert
  • always

formula string

SQL expression that defines the value of the property. If you specify a formula, the column value is ignored.

lazy string

Specifies if loading is to be done by parts:
Values:
  • extra

optimisticLock boolean

Whether updates to this property require acquisition of the optimistic lock on the table row

scale string

Specifies the scale value

mappedby string

Property in the target CFC that is referenced by the foreign key in the Join table.

cfc string

Name of referenced CFC

joinColumn string

Use this attribute to define the join column for inheritance mapping.

validate string

Takes the validator to be used for validating data when implicit setter for this property is called.
Values:
  • string
  • boolean
  • integer
  • numeric
  • date
  • time
  • creditcard
  • email
  • eurodate
  • ssn
  • telephone
  • UUID
  • guid
  • zipcode

validateParams string

Takes the parameters required by the validator specified in the validate attribute.
This should be specified in the implicit struct notation eg. validateparams="{min=18,max=60}">.

min: Minimum value if validate is integer/numeric/
max: Maximum value if the validate is integer/numeric/
minLength: Minimum length of the string if the validate is string
maxLength: Maximum length of the string if the validate is string
pattern: regex expression if the validator specified in validate attribute is regex

cacheUse string

Type of cache to use
Values:
  • read-only
  • nonstrict-read-write
  • read-write
  • transactional

sqlType string

Use this attribute to specify the DB-specific SQLType that should be used for the column. This attribute is used for table creation only.
If this attribute is not specified, ColdFusion will automatically decide the SQLType based on the ormtype specified for this property.

dbDefault string

This sets the default value of a column in the table when schema is exported.

where string

Where condition

persistent boolean

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.

unSavedValue string

An identifier property value that indicates that an instance is newly instantiated and not saved/loaded in the database

serializable boolean

Specifies whether this property can be serialized. If you set this value to
false, the property cannot be serialized, so any changes made are not retained on session replication, and the property has its default value (if any) on the second server.
Use this attribute to prevent serialization of properties in CFCs that are serializable.

singularname string

Use this property to define the custom name for generated relationship methods. Applies to one-to-many and many-to-many

remotingFetch boolean

If remotingFetch is false, then the value of that attribute is not sent over flash remoting. remotingFetch is true by default was all properties. But in case of cfcs for which persistent = true, the value of the remotingFetch attribute is false by default for any property that shares one-to-one, one-to-many, many-to-one or many-to-many relationship.
Values:
  • false
  • true

table string

Table name

Examples
Sample code using the cfproperty tag

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub