Working With Objects - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM

Working with objects

Operations can be performed on an Entity object, and the auto-generated methods in the entity can be called.
Generated accessors
As described in
Define ORM
ColdFusion generates the accessor methods (getter and setter) for each property in the CFC that can be invoked. For
more information, see
Implicit Get and Set
<cfproperty name="firstName" >
There are two methods generated in the Artist object:
setFirstName(firstName)
getFirstName()
You can invoke these methods like regular methods in the CFC. For a property, the generated setter saves the value for
the property in the object's VARIABLES scope. The generated getter retrieves the value of the property from the
VARIABLES scope. ORM always uses the property value from the VARIABLES scope. That is, while saving the object's
data in the table, ORM retrieves the value of the property from VARIABLES scope. While populating the object after
reading from the table, ORM puts the property's value in the VARIABLES scope.If you define your own accessor
methods for a property, store the property value in the VARIABLES scope for ORM to access it.
Generated methods for relationships between CFCs
When a relationship is defined in a CFC, ColdFusion generates a few methods in the CFC object to add or remove
associated objects and to check their existence, for each relationship defined in the CFC.
The generated methods for relationships include:
add<relationship_property_name>()
This method is generated for one-to-many and many-to-many relationships. The method adds the given object to
the association collection (array or struct) of the component. For a bidirectional relationship, this method does not
set the association on the other end.
For
, the method signature is:
type="array"
add<relationship_property_name>(<associated_object>)
For
, the method signature is:
type="struct"
add<relationship_property_name>(<key>, <associated_object>)
boolean remove<relationship_property_name>()
This method is generated for one-to-many and many-to-many relationships. The method removes the object from
the associated collection (array or struct) of the component. If the associated object was removed from the
collection successfully, then true is returned. For a bidirectional relationship, this method does not remove the
association from the other end.
For
, the method signature is:
type="array"
boolean remove<relationship_property_name>(<associated_object>)
For
, the method signature is:
type="struct"
boolean remove<relationship_property_name>(<key>).
mapping, the persistent fields for an object are defined in the CFC using
Functions. For example, if a property is defined in Artist as follows:
Last updated 1/20/2012
575
.
cfproperty

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents