Adobe COLDFUSION 9 Manual page 590

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
<cftransaction>
<cfset acct1 = EntityLoad("Account", "101")>
<cfset acct2 = EntityLoad("Account", "102")>
<cfset acct1.debit(1000)>
<cfset acct2.credit(1000)>
<cfset EntitySave(acct1)>
<cfset EntitySave(acct2)>
</cftransaction>
Because we have not called commit on the
ends.
<cftransaction>
All
semantics including savepoint, multiple rollbacks, multiple commits, and nested transactions
<cftransaction>
work with ORM. You can also have both queries and ORM in the same
When
begins, any existing ORM session is flushed and closed, and a new ORM session is created.
<cftransaction>
The
can be committed or rolled back using appropriate ColdFusion tags in
<cftransaction>
When the transaction ends and has not been committed or rolled back explicitly, it is automatically committed and
the ORM session is closed. If there is any error inside the transaction, without any exception handling, the transaction
is rolled back.
For more details on
<cftransaction>
Note: Even if ORMFlush() is called explicitly inside a <cftransaction> tag, the SQL runs but the data is committed only
when the transaction commits.
Change of behavior in ColdFusion 9 Update 1
When..
When the transaction starts
When the transaction is committed
When the transaction is rolled back
Optimistic locking
A
could prevent scalability in highly concurrent applications because it locks a database for a
<cftransaction>
transaction that could run for a longer time. Also, a transaction cannot run beyond the duration of a request. There
can be scenarios where an object is loaded in one request and the same instance is updated in another request or by
another application. In this scenario, the application needs to maintain the transaction semantics and prevent the
update if the row has been modified by some other request. This can be achieved by using optimistic concurrency
control, which allows high concurrency in your application along with high scalability.
Optimistic concurrency control uses either number-based or timestamp-based versioning approach. In a number-
based approach, a version number is incremented and for the timestamp approach, a timestamp is set to the current
time whenever the object is modified. It must be noted that version increment or timestamp updation is managed by
Hibernate and is not triggered at the database level.
• Using version: To use optimistic concurrency control using version numbers, add a property with
in your CFC.
fieldtype='version'
For example:
<cftransaction>
, see the CFML Reference Guide.
Behavior in ColdFusion 9
The existing session closes and a new session starts.
The existing session is flushed and closed.
The existing session is closed without flushing.
Last updated 8/5/2010
specifically, it is automatically committed when the
<cftransaction>
Changed behavior
The existing session is flushed and is reused.
The existing session is flushed.
The existing session is cleared.
.
.
<cftransaction>
585

Advertisement

Table of Contents
loading

Table of Contents