Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 591

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
/**
* @persistent
* @table Users
*/
component{
property name="id" fieldtype="id" datatype="int" generator="native";
property string fname;
property string lname;
property name="version" fieldtype="version" datatype="int" ;
}
Whenever a user object is updated, its version number is automatically incremented. The version number is used
in the SQL update statement in such a way that updating proceeds only when the version number has not been
changed by some other request or some other application.
In case updating fails because the version number was changed outside the current session, an error is thrown
specifying that the session contained stale data.
• Using timestamp: To use optimistic concurrency control using timestamp, add a property with
fieldtype="timestamp"
For example:
/**
* @persistent
* @table Users
*/
component{
property name="id" fieldtype="id" datatype="int" generator="native";
property string fname;
property string lname;
property name="lastModified" fieldtype="timestamp";
}
Whenever a user object is updated, its timestamp is automatically set to the current time. Sometimes this is
preferred over version because it also tells you when the user object was last modified.
In case updating fails because the timestamp was changed outside of the current session, an error is thrown
specifying that the session contained stale data.
If you do not have version or timestamp properties in your object, it is still possible to use optimistic locking, but only
for objects that are retrieved and modified in the same ORM session. For optimistic locking of detached objects
(objects that were loaded in some other request/ORM session), you must use a version number or timestamp.
To use optimistic locking for objects that do not have version or timestamp, you need to set attribute
on the CFC. This attribute can take the following values:
lock'
: This means that all the properties are included in the
all
(default): This means that only the modified properties are included in the
dirty
: This means that only the version field is included in the
version
: This means that none of the properties are included in the
none
concurrency is disabled for that component.
Example:
in your CFC.
Last updated 1/20/2012
clause of update query.
where
where
clause of update query.
where
clause, which in effect means that optimistic
where
'optimistic-
clause of the update query.
586

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents