Orm Session Management - 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
Edit ehCache.xml (cfroot/lib)to set the properties for user-defined caches as shown in the following example:
<!--- item to put in user-defined cache --->
<cfset currentTime = Now()>
<!--- put item in user-defined cache --->
<cfset timeToLive=createtimespan(0,0,0,30)>
<cfset timeToIdle=createtimespan(0,0,0,30)>
<cfset customCache = "usercache">
<cfset id = "cache1">
<cfset cachePut(id,currentTime,timeToLive,timeToIdle,customCache)>
<!-- list items in the cache --->
List Items in cache:
<cfset cacheIds = cacheGetAllIds(customCache)>
<cfdump var="#cacheIds#"><br>
<!--- print cache data --->
<cfset cachedData = cacheGet(id,customCache)>
<cfoutput>#cachedData#</cfoutput>
<!--- print cache metadata --->
Cache metadata:
<cfset mdata = cacheGetMetadata(id,"object",customCache)>
<cfdump var="#mdata#">
<!--- clear user-defined cache --->
<cfset cacheRemove(ArrayToList(cacheIds),true,customCache)>

ORM session management

Hibernate Session is a thread-safe and short-lived object that represents a conversation between the application and
the persistence layer. This is required to perform CRUD operations (Create, Delete, Update, Retrieval) on a persistent
entity in Hibernate. For ColdFusion applications that use ORM, this session is automatically managed by ColdFusion.
Hibernate sessions also act as the first level of cache, which ensures that only one copy of an object exists in the session.
When CRUD operations are performed in the session, data of the entity is not synchronized with the database
immediately. That is, the SQL statements for the operations are not issued immediately and they are queued. The data
is synchronized with the database when the session is flushed. When the session is flushed, the SQL operations are
performed in the following order:
all entity insertions, in the same order the corresponding objects were saved using
1
all entity updates
2
3
all collection deletions
4
all collection element deletions, updates, and insertions
all collection insertions
5
6
all entity deletions, in the same order the corresponding objects were deleted using
The only exception to this is that objects with nativeId generation are inserted immediately when the object is saved.
Note: ColdFusion creates and manages Hibernate sessions only if
When the ColdFusion application starts, it builds the Hibernate session factory that is available for the application life
time. This factory is used to create Hibernate sessions that manage the persistent object lifecycle. When the first CRUD
method is called, a Hibernate session gets created and is closed when the request ends or when the
is called. For details on how ColdFusion works with Hibernate, see the "Architecture" on
ormclosesessionmethod
page 537.
ormenabled
Last updated 1/20/2012
EntitySave()
EntityDelete()
is set to
in application scope.
true
595

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents