Properties
Entity properties are how we map table columns to CFML object values. You can specify an entity property by setting persistent="true"
on any property
inside a persistent CFML component:
By default, all properties inside a persistent=true
component are assumed to be persistent as well. Thus, we can skip the persistent=true
annotation for brevity:
Common Property Annotations
Attribute | Type | Description |
---|---|---|
|
| Define this property as a persistent property. If |
|
| Property name |
|
| Default value for the property. This only reaches the CFML engine, and does not affect creation of the entity table. |
|
| Table column where the property value is stored. |
|
| Set the default value for the property. |
Make sure you quote datetime dbdefault
values to avoid invalid date errors in MySQL:
Property Types
There are several "type" concepts and annotations you may need to use to keep the proper format when persisting or retrieving table data. While these may look similar, they are not equivalent.
Attribute | Examples | Description |
---|---|---|
|
| CFML data type |
|
| Denote a special type of field, like an identifier or relationship field. |
|
| Data type for the database value. |
|
| A vendor-specific SQL type used for table creation only. This can normally be ignored. |
Field Type
The fieldtype
attribute allows you to define the behavior and purpose of this property:
There are several options for the fieldtype
value:
column
- By far the most common, this is the default behavior of every field.id
- Notes this field as the primary key or part of the a composite key.collection
- Denote a collection of items - this could represent a struct, an arrayversion
- Denote a version field, useful for optimistic locking on an entitytimestamp
- Denote a timestamp fieldone-to-one
- Denote a one-to-one relationshipone-to-many
- Denote a one-to-many relationshipmany-to-one
- Denote a many-to-one relationshipmany-to-many
- Denote a many-to-many relationshipprimary
- Not currently used.
Generator Annotations
Attribute | Type | Description |
---|---|---|
|
| One of |
|
|
|
|
| |
|
| Only used with |
|
|
|
Validation
Attribute | Type | Description |
---|---|---|
|
| Allow inserting values to new rows. |
|
| Allow value updates on existing rows. |
|
| Specify a not-null constraint. |
|
| Specify a key name for a unique constraint. Useful for defining a unique constraint across multiple columns. |
|
| Specify a unique constraint. Default |
|
| Not currently supported |
|
| Not currently supported |
Collection Modifiers
These property annotations are used when setting fieldtype="collection"
and collectiontype
is either struct
or map
.
Attribute | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
|
Relationship Modifiers
Attribute | Type | Description |
---|---|---|
|
| Define the table where the foreign items are stored. |
|
| Define a lazy association retrieval type. One of |
|
| Specify that the association "owner" is referenced and managed on the opposite entity - not this current entity. |
|
| Specify the join column on the associated entity. For |
|
| Specify the schema name of the link table |
|
| Specify the catalog name of the link table |
|
| Specify the name of the link table |
|
| Do not throw an error if a foreign key has no match in the foreign entity |
|
| |
|
| |
|
| |
|
| |
|
| Only valid for |
|
| Enable optimistic locking on this association. One of |
|
| Specify the property on the association that maps to this entity. |
|
| Specify the CFC location of the foreign entity. |
|
| Join the foreign entity on this column in this entity. |
|
| Arbitrary SQL where clause for the relation. |
| Not currently supported |
Other
Attribute | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| Define this property as a computed property by using a SQL query to determine the property value. Formula properties cannot be modified. |
|
| Key name for a property value index. |
|
| Define a cache type to use for this property. One of |
|
| Set the name of the cache to use for this property. |
|
| Set a value to use for newly instantiated objects. |
Formula Property
Unsupported Attributes
Looking for better support of a specific persistent attribute? Contact our Support team to consider sponsoring this feature.
Last updated