SlideShare a Scribd company logo
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1
www.rupeshk.org/blog
rukumar
Advanced ColdFusion-ORM
#adobemax348
Rupesh Kumar
Senior Computer Scientist
Adobe Systems Inc.
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 2
Agenda
 ORM Basics
 Demo
 Advanced Mapping
 What happens internally
 Transaction & concurrency control
 Caching & optimization
 Event Handling
 Auto-generation of tables
 Q & A
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 3
ORM Basics
 Object - Relational Mapping
 A persistence framework to map objects to the relational database
without writing SQL.
 A programming technique for converting data between incompatible
type systems in relational databases and object-oriented programming
languages.
 ColdFusion ORM – based on Hibernate
 One of the most mature and popular persistence framework
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 5
EMPLOYEES
EmployeeID(PK)
LastName
FirstName
Title
Database Model – Employees
ORDERS
OrderID(PK)
EmployeeID
OrderDate
1
n
ADDRESSES
AddressID(PK)
HouseNumber
Street
City
State
Country
EmployeeID
TERRITORIES
TerritoryID(PK)
TerritoryDescription
EMPLOYEETERRITORIES
EmployeeID(PK)
TerritoryID(PK)
1
1
m
n
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 6
Demo
 ORM Settings
 Mapping a Simple CFC
 CRUD Methods
 Relationships
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 7
Advanced Mapping
 Collection Mapping
 Inheritance Mapping
 Embedded Mapping
 Join Mapping
 Using Hibernate mapping files directly
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 9
Inheritance Mapping
 Three Types
 Table per hierarchy
Payment
+ID
+Amount
+Date
CreditCardPayme
nt
+CardNo
+CardType
ChequePayment
+ChequeNo
+bankName
+City
ID <<PK>>
Amount
Date
PaymentType
(discriminator)
CardNo
CardType
ChequeNo
BankName
City
Payment Table
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 10
Inheritance Mapping
 Three Types
 Table per hierarchy
 Table per subclass
Payment
+ID
+Amount
+Date
CreditCardPayme
nt
+CardNo
+CardType
ChequePayment
+ChequeNo
+bankName
+City
ID <<PK>>
Amount
Date
Payment Table
PaymentID
CardNo
CardType
CreditCardPayment Table
PaymentId
ChequeNo
BankName
City
Cheque Payment Table
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 11
Inheritance Mapping
 Three Types
 Table per hierarchy
 Table per subclass
 Table per subclass with discriminator
Payment
+ID
+Amount
+Date
CreditCardPayme
nt
+CardNo
+CardType
ChequePayment
+ChequeNo
+bankName
+City
ID <<PK>>
Amount
Date
PaymentType
(discriminator)
Payment Table
PaymentID
CardNo
CardType
CreditCardPayment Table
PaymentId
ChequeNo
BankName
City
Cheque Payment Table
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 13
Join Mapping
 Useful when using one CFC for multiple tables
<cfcomponent persistent="true“ table=“Person”>
<cfproperty name="id">
<cfproperty name="name">
<cfproperty name="city"
table="Address” joincolumn=“personId">
<cfproperty name="country"
table="Address“ joincolumn=“personId">
</cfcomponent>
ADDRESS
PersonID
HouseNumber
Street
City
State
Country
Person
ID(PK)
Name
email
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 14
Application
Start
ORM
Enable
d?
Proceed
with other
activities
false
true
Create/Load
Hibernate
configuration if
specified
Load Hibernate
mapping files
(*.hbmxml)
Search for persistent
CFCs
Generate Hibernate
Mapping for
persistent CFCs
DatabaseInspect
Generate DDL
based on dbcreate
Build Hibernate
Session Factory
Proceed
with other
activities
ORM Initialization
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 15
ORM Session
 Represents a unit of work – typically a transaction
 All the ORM operations happen in a session
 Provides First Level Caching
 Ensures a single instance of an entity.
 Tracks changes made to the objects
 SQLs are executed when session is flushed
 Typically when the transaction is committed or when the request completes
 Can use ORMFlush to force
 Automatically managed by CF
 In most cases, you don’t need to worry about it
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 16
ORM Session Management
New Request
New ORM Session
Call ORMFlush
Close Session
Batch all the operations
Application
Start
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 17
ORM Session Management – Transactions
17
New Request
New ORM Session
Application
Start
Call ORMFlush
Close ORM Session
New ORM Session
Call ORMFlush
Close ORM Session
Batch all the operations
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 18
Object States
 Transient
 Persistent
 Detached
EntityNew()/ new()/
CreateObject
Transient Entity
Persistent Entities
EntitySave()
DB
Detached
Session ends
EntityLoad
ORMExecuteQuery
EnityMerge
EntityDelete
EntitySave
Session
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 19
Concurrency Control
 Optimistic lock for high concurrency
 Update only if the entity is not modified by other thread or externally.
 optimisticlock attribute on cfc
 All
 All properties are included in where clause of update
Update myTbl set col1= newVal, col2= newVal2
where col1= oldVal and col2= oldVal2
 Dirty
 Includes only modified fields in the current session
 Version (default)
 Checks only version or timestamp column
<cfproperty name="lastModified“ fieldtype="timestamp|version“>
 None
 You can also choose the property for dirty check.
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 20
Fetching Strategy
 Immediate fetching
 Fetch target relationship in a separate SQL, immediately
<cfproperty name=“emp" fieldtype="one-to-many" cfc=“order"
fkcolumn=“EMPID“ lazy="false" fetch="select">
 Lazy fetching
 Default strategy, lazy=true
 On demand, fetch related entities
 Lazy = “extra” gets pk of orders and then all order columns from db
 Eager fetching
 Fetch together in a single SQL, fetch=“join”
 Useful for 1:1 frequently used relationships
 Batch fetching
 When fetching relationship, get some more that maybe required later
 Get Addr1 for emp101, plus address for emp102, 103 etc from the table depending on
batch size
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 21
Caching
 Session Level
 Ensures a single instance for a given ID
 EntityLoad fetches data for the first time
 Data is cached for the session
 Next request in the same session will use cached data
 EntityReload re-fetches
 Secondary Level Cache
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 22
Secondary Level Cache
 Caches data across sessions
 In-memory/disk/clustered
 Pluggable cache impls
 Default - EHCache
 Component Caching
 Collection Caching
 Query Caching
Secondary Cache
…
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 23
Secondary Level caching ...
 Configuration in Application.cfc
 ormsettings.secondarycacheenabled
 ormsettings.Cacheprovider
 JBossCache, OSCache, SwarmCache, Hashtable, DEFAULT - ehcache
 ormsettings.cacheconfig
 Appropriate config file for cache, e.g. ehcache.xml
 In ORM cfc
 “cacheuse” defines caching strategy
 “cahcename” cache region, a bucket for this data
<cfcomponent persistent="true“
cachename=“foo_region" cacheuse="read-only">
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 24
Caching - examples
 Component
 <cfcomponent persistent="true“
cachename=“foo_region" cacheuse="read-only">
 Relationship
 Primary Key of the associated object is cached
 The associated object itself is cached if coded as above
<cfproperty name="arts" fieldtype="one-to-many“
cachename="foo_region" cacheuse="read-write">
 Query data
ORMExecuteQuery("from Art where issold=0", {}, false,
{cacheable=true, cachename=“foo_region"});
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 25
Caching – cacheuse
 Read-only
 Best performance for read only data
 Nonrestrict-read-write
 Use when data is updated occasionally
 Read-write
 Use if your data needs to be updated
 More overhead than the two preceding strategies
 Transactional
 Transactional cache
 Can only be used if the cache provider is transaction aware
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 26
Caching - cleanup
 ORMEvictEntity
ORMEvictEntity("<component_name>", [primarykey])
 ORMEvictCollection
ORMEvictCollection("<component_name>", "<relation_name>",
[primarykey])
 ORMEvictQueries
ORMEvictQueries([cachename])
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 27
Event Handling
 Set ormsettings.eventhandling=“true”
 CFC level
 preinsert and postinsert
 predelete and postdelete
 preupdate and postupdate
 preload and postload
 Application Level
 Set ormsettings.eventhandler=“AppEventHandler.cfc”
 Should implement the CFIDE.orm.IEventHandler interface
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 28
Auto-generating tables
 Tables created on Application startup
 ormsettings.dbcreate
 Update – create new or update if table exists
 Dropcreate – drop and then create table
 None – do nothing
 ormsettings.sqlscript
 Executes the sql script at the time of table creation.
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 29
Naming Strategy
 Defines the strategy for naming tables and columns
 ormsettings.namingStrategy
 Default – CFC/property name matches table/column name
 Smart – camel cased name is uppercased with “_” between words.
 CFC “OrderProduct” is “ORDER_PRODUCT”, OrderID is “ORDER_ID”
 Your own CFC that implements cfide.orm.INamingStrategy
Component UCaseStrategy implements cfide.orm.INamingStrategy
{
public string function getTableName(string tableName)
{
return Ucase(tableName);
}
public string function getColumnName(string columnName)
{
return Ucase(columnName);
}
}
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 30
Q & A
®
Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 31
Thank You !
- rukumar@adobe.com
- http://www.rupeshk.org
Ad

More Related Content

What's hot (20)

Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
BigDataEverywhere
 
All you need to know about CREATE STATISTICS
All you need to know about CREATE STATISTICSAll you need to know about CREATE STATISTICS
All you need to know about CREATE STATISTICS
EDB
 
Pig_Presentation
Pig_PresentationPig_Presentation
Pig_Presentation
Arjun Shah
 
Add Powerful Full Text Search to Your Web App with Solr
Add Powerful Full Text Search to Your Web App with SolrAdd Powerful Full Text Search to Your Web App with Solr
Add Powerful Full Text Search to Your Web App with Solr
adunne
 
Oracle adapters for Ruby ORMs
Oracle adapters for Ruby ORMsOracle adapters for Ruby ORMs
Oracle adapters for Ruby ORMs
Raimonds Simanovskis
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
zznate
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
Mydbops
 
Streamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache AmbariStreamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache Ambari
Alejandro Fernandez
 
mod_rewrite bootcamp, Ohio LInux 2011
mod_rewrite bootcamp, Ohio LInux 2011mod_rewrite bootcamp, Ohio LInux 2011
mod_rewrite bootcamp, Ohio LInux 2011
Rich Bowen
 
Hadoop Pig
Hadoop PigHadoop Pig
Hadoop Pig
Madhur Nawandar
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
DataStax
 
Advanced Relevancy Ranking
Advanced Relevancy RankingAdvanced Relevancy Ranking
Advanced Relevancy Ranking
Search Technologies
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
guest9912e5
 
Quick trip around the Cosmos - Things every astronaut supposed to know
Quick trip around the Cosmos - Things every astronaut supposed to knowQuick trip around the Cosmos - Things every astronaut supposed to know
Quick trip around the Cosmos - Things every astronaut supposed to know
Rafał Hryniewski
 
An Introduction to Basics of Search and Relevancy with Apache Solr
An Introduction to Basics of Search and Relevancy with Apache SolrAn Introduction to Basics of Search and Relevancy with Apache Solr
An Introduction to Basics of Search and Relevancy with Apache Solr
Lucidworks (Archived)
 
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String MethodsPython Programming Essentials - M8 - String Methods
Python Programming Essentials - M8 - String Methods
P3 InfoTech Solutions Pvt. Ltd.
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2
Charles Givre
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
MongoDB
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
Ralph Schindler
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant) Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
Big Data Everywhere Chicago: Unleash the Power of HBase Shell (Conversant)
BigDataEverywhere
 
All you need to know about CREATE STATISTICS
All you need to know about CREATE STATISTICSAll you need to know about CREATE STATISTICS
All you need to know about CREATE STATISTICS
EDB
 
Pig_Presentation
Pig_PresentationPig_Presentation
Pig_Presentation
Arjun Shah
 
Add Powerful Full Text Search to Your Web App with Solr
Add Powerful Full Text Search to Your Web App with SolrAdd Powerful Full Text Search to Your Web App with Solr
Add Powerful Full Text Search to Your Web App with Solr
adunne
 
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
zznate
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
Mydbops
 
Streamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache AmbariStreamline Hadoop DevOps with Apache Ambari
Streamline Hadoop DevOps with Apache Ambari
Alejandro Fernandez
 
mod_rewrite bootcamp, Ohio LInux 2011
mod_rewrite bootcamp, Ohio LInux 2011mod_rewrite bootcamp, Ohio LInux 2011
mod_rewrite bootcamp, Ohio LInux 2011
Rich Bowen
 
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
CQL performance with Apache Cassandra 3.0 (Aaron Morton, The Last Pickle) | C...
DataStax
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
guest9912e5
 
Quick trip around the Cosmos - Things every astronaut supposed to know
Quick trip around the Cosmos - Things every astronaut supposed to knowQuick trip around the Cosmos - Things every astronaut supposed to know
Quick trip around the Cosmos - Things every astronaut supposed to know
Rafał Hryniewski
 
An Introduction to Basics of Search and Relevancy with Apache Solr
An Introduction to Basics of Search and Relevancy with Apache SolrAn Introduction to Basics of Search and Relevancy with Apache Solr
An Introduction to Basics of Search and Relevancy with Apache Solr
Lucidworks (Archived)
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2
Charles Givre
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
MongoDB
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 

Viewers also liked (6)

ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013
Rupesh Kumar
 
ColdFusion 9 ORM
ColdFusion 9 ORMColdFusion 9 ORM
ColdFusion 9 ORM
Rupesh Kumar
 
Shooting the Rapids
Shooting the RapidsShooting the Rapids
Shooting the Rapids
Maurice Naftalin
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007
Rupesh Kumar
 
ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006
Rupesh Kumar
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
Maurice Naftalin
 
ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013
Rupesh Kumar
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007
Rupesh Kumar
 
ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006ColdFusion .NET integration - Adobe Max 2006
ColdFusion .NET integration - Adobe Max 2006
Rupesh Kumar
 
Ad

Similar to ColdFusion ORM - Advanced : Adobe Max 2009 (20)

ColdFusion ORM - Part II
ColdFusion ORM - Part II  ColdFusion ORM - Part II
ColdFusion ORM - Part II
Rupesh Kumar
 
Language enhancements in cold fusion 11
Language enhancements in cold fusion 11Language enhancements in cold fusion 11
Language enhancements in cold fusion 11
ColdFusionConference
 
London HUG 12/4
London HUG 12/4London HUG 12/4
London HUG 12/4
London HashiCorp User Group
 
Cast Iron Cloud Integration Best Practices
Cast Iron Cloud Integration Best PracticesCast Iron Cloud Integration Best Practices
Cast Iron Cloud Integration Best Practices
Sarath Ambadas
 
Php Site Optimization
Php Site OptimizationPhp Site Optimization
Php Site Optimization
Amit Kejriwal
 
Hibernate in Nutshell
Hibernate in NutshellHibernate in Nutshell
Hibernate in Nutshell
Onkar Deshpande
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
grooverdan
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
Jinal Jhaveri
 
Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015
Chef
 
Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)
ThirdWaveInsights
 
Terraform Cosmos DB
Terraform Cosmos DBTerraform Cosmos DB
Terraform Cosmos DB
Moisés Elías Araya
 
php & performance
 php & performance php & performance
php & performance
simon8410
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
ColdFusionConference
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data access
gordonyorke
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”
Ruggero Citton
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
Sadayuki Furuhashi
 
TIAD : Automating the modern datacenter
TIAD : Automating the modern datacenterTIAD : Automating the modern datacenter
TIAD : Automating the modern datacenter
The Incredible Automation Day
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
毅 吕
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
NETWAYS
 
Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02
arghya007
 
ColdFusion ORM - Part II
ColdFusion ORM - Part II  ColdFusion ORM - Part II
ColdFusion ORM - Part II
Rupesh Kumar
 
Language enhancements in cold fusion 11
Language enhancements in cold fusion 11Language enhancements in cold fusion 11
Language enhancements in cold fusion 11
ColdFusionConference
 
Cast Iron Cloud Integration Best Practices
Cast Iron Cloud Integration Best PracticesCast Iron Cloud Integration Best Practices
Cast Iron Cloud Integration Best Practices
Sarath Ambadas
 
Php Site Optimization
Php Site OptimizationPhp Site Optimization
Php Site Optimization
Amit Kejriwal
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
grooverdan
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
Jinal Jhaveri
 
Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015
Chef
 
Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)
ThirdWaveInsights
 
php & performance
 php & performance php & performance
php & performance
simon8410
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using CachingAccelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
ColdFusionConference
 
Accelerated data access
Accelerated data accessAccelerated data access
Accelerated data access
gordonyorke
 
gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”gDBClone - Database Clone “onecommand Automation Tool”
gDBClone - Database Clone “onecommand Automation Tool”
Ruggero Citton
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
Sadayuki Furuhashi
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
毅 吕
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
NETWAYS
 
Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02Red5workshop 090619073420-phpapp02
Red5workshop 090619073420-phpapp02
arghya007
 
Ad

Recently uploaded (20)

HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 

ColdFusion ORM - Advanced : Adobe Max 2009

  • 1. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1 www.rupeshk.org/blog rukumar Advanced ColdFusion-ORM #adobemax348 Rupesh Kumar Senior Computer Scientist Adobe Systems Inc.
  • 2. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 2 Agenda  ORM Basics  Demo  Advanced Mapping  What happens internally  Transaction & concurrency control  Caching & optimization  Event Handling  Auto-generation of tables  Q & A
  • 3. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 3 ORM Basics  Object - Relational Mapping  A persistence framework to map objects to the relational database without writing SQL.  A programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.  ColdFusion ORM – based on Hibernate  One of the most mature and popular persistence framework
  • 4. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 5 EMPLOYEES EmployeeID(PK) LastName FirstName Title Database Model – Employees ORDERS OrderID(PK) EmployeeID OrderDate 1 n ADDRESSES AddressID(PK) HouseNumber Street City State Country EmployeeID TERRITORIES TerritoryID(PK) TerritoryDescription EMPLOYEETERRITORIES EmployeeID(PK) TerritoryID(PK) 1 1 m n
  • 5. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 6 Demo  ORM Settings  Mapping a Simple CFC  CRUD Methods  Relationships
  • 6. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 7 Advanced Mapping  Collection Mapping  Inheritance Mapping  Embedded Mapping  Join Mapping  Using Hibernate mapping files directly
  • 7. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 9 Inheritance Mapping  Three Types  Table per hierarchy Payment +ID +Amount +Date CreditCardPayme nt +CardNo +CardType ChequePayment +ChequeNo +bankName +City ID <<PK>> Amount Date PaymentType (discriminator) CardNo CardType ChequeNo BankName City Payment Table
  • 8. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 10 Inheritance Mapping  Three Types  Table per hierarchy  Table per subclass Payment +ID +Amount +Date CreditCardPayme nt +CardNo +CardType ChequePayment +ChequeNo +bankName +City ID <<PK>> Amount Date Payment Table PaymentID CardNo CardType CreditCardPayment Table PaymentId ChequeNo BankName City Cheque Payment Table
  • 9. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 11 Inheritance Mapping  Three Types  Table per hierarchy  Table per subclass  Table per subclass with discriminator Payment +ID +Amount +Date CreditCardPayme nt +CardNo +CardType ChequePayment +ChequeNo +bankName +City ID <<PK>> Amount Date PaymentType (discriminator) Payment Table PaymentID CardNo CardType CreditCardPayment Table PaymentId ChequeNo BankName City Cheque Payment Table
  • 10. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 13 Join Mapping  Useful when using one CFC for multiple tables <cfcomponent persistent="true“ table=“Person”> <cfproperty name="id"> <cfproperty name="name"> <cfproperty name="city" table="Address” joincolumn=“personId"> <cfproperty name="country" table="Address“ joincolumn=“personId"> </cfcomponent> ADDRESS PersonID HouseNumber Street City State Country Person ID(PK) Name email
  • 11. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 14 Application Start ORM Enable d? Proceed with other activities false true Create/Load Hibernate configuration if specified Load Hibernate mapping files (*.hbmxml) Search for persistent CFCs Generate Hibernate Mapping for persistent CFCs DatabaseInspect Generate DDL based on dbcreate Build Hibernate Session Factory Proceed with other activities ORM Initialization
  • 12. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 15 ORM Session  Represents a unit of work – typically a transaction  All the ORM operations happen in a session  Provides First Level Caching  Ensures a single instance of an entity.  Tracks changes made to the objects  SQLs are executed when session is flushed  Typically when the transaction is committed or when the request completes  Can use ORMFlush to force  Automatically managed by CF  In most cases, you don’t need to worry about it
  • 13. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 16 ORM Session Management New Request New ORM Session Call ORMFlush Close Session Batch all the operations Application Start
  • 14. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 17 ORM Session Management – Transactions 17 New Request New ORM Session Application Start Call ORMFlush Close ORM Session New ORM Session Call ORMFlush Close ORM Session Batch all the operations
  • 15. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 18 Object States  Transient  Persistent  Detached EntityNew()/ new()/ CreateObject Transient Entity Persistent Entities EntitySave() DB Detached Session ends EntityLoad ORMExecuteQuery EnityMerge EntityDelete EntitySave Session
  • 16. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 19 Concurrency Control  Optimistic lock for high concurrency  Update only if the entity is not modified by other thread or externally.  optimisticlock attribute on cfc  All  All properties are included in where clause of update Update myTbl set col1= newVal, col2= newVal2 where col1= oldVal and col2= oldVal2  Dirty  Includes only modified fields in the current session  Version (default)  Checks only version or timestamp column <cfproperty name="lastModified“ fieldtype="timestamp|version“>  None  You can also choose the property for dirty check.
  • 17. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 20 Fetching Strategy  Immediate fetching  Fetch target relationship in a separate SQL, immediately <cfproperty name=“emp" fieldtype="one-to-many" cfc=“order" fkcolumn=“EMPID“ lazy="false" fetch="select">  Lazy fetching  Default strategy, lazy=true  On demand, fetch related entities  Lazy = “extra” gets pk of orders and then all order columns from db  Eager fetching  Fetch together in a single SQL, fetch=“join”  Useful for 1:1 frequently used relationships  Batch fetching  When fetching relationship, get some more that maybe required later  Get Addr1 for emp101, plus address for emp102, 103 etc from the table depending on batch size
  • 18. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 21 Caching  Session Level  Ensures a single instance for a given ID  EntityLoad fetches data for the first time  Data is cached for the session  Next request in the same session will use cached data  EntityReload re-fetches  Secondary Level Cache
  • 19. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 22 Secondary Level Cache  Caches data across sessions  In-memory/disk/clustered  Pluggable cache impls  Default - EHCache  Component Caching  Collection Caching  Query Caching Secondary Cache …
  • 20. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 23 Secondary Level caching ...  Configuration in Application.cfc  ormsettings.secondarycacheenabled  ormsettings.Cacheprovider  JBossCache, OSCache, SwarmCache, Hashtable, DEFAULT - ehcache  ormsettings.cacheconfig  Appropriate config file for cache, e.g. ehcache.xml  In ORM cfc  “cacheuse” defines caching strategy  “cahcename” cache region, a bucket for this data <cfcomponent persistent="true“ cachename=“foo_region" cacheuse="read-only">
  • 21. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 24 Caching - examples  Component  <cfcomponent persistent="true“ cachename=“foo_region" cacheuse="read-only">  Relationship  Primary Key of the associated object is cached  The associated object itself is cached if coded as above <cfproperty name="arts" fieldtype="one-to-many“ cachename="foo_region" cacheuse="read-write">  Query data ORMExecuteQuery("from Art where issold=0", {}, false, {cacheable=true, cachename=“foo_region"});
  • 22. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 25 Caching – cacheuse  Read-only  Best performance for read only data  Nonrestrict-read-write  Use when data is updated occasionally  Read-write  Use if your data needs to be updated  More overhead than the two preceding strategies  Transactional  Transactional cache  Can only be used if the cache provider is transaction aware
  • 23. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 26 Caching - cleanup  ORMEvictEntity ORMEvictEntity("<component_name>", [primarykey])  ORMEvictCollection ORMEvictCollection("<component_name>", "<relation_name>", [primarykey])  ORMEvictQueries ORMEvictQueries([cachename])
  • 24. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 27 Event Handling  Set ormsettings.eventhandling=“true”  CFC level  preinsert and postinsert  predelete and postdelete  preupdate and postupdate  preload and postload  Application Level  Set ormsettings.eventhandler=“AppEventHandler.cfc”  Should implement the CFIDE.orm.IEventHandler interface
  • 25. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 28 Auto-generating tables  Tables created on Application startup  ormsettings.dbcreate  Update – create new or update if table exists  Dropcreate – drop and then create table  None – do nothing  ormsettings.sqlscript  Executes the sql script at the time of table creation.
  • 26. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 29 Naming Strategy  Defines the strategy for naming tables and columns  ormsettings.namingStrategy  Default – CFC/property name matches table/column name  Smart – camel cased name is uppercased with “_” between words.  CFC “OrderProduct” is “ORDER_PRODUCT”, OrderID is “ORDER_ID”  Your own CFC that implements cfide.orm.INamingStrategy Component UCaseStrategy implements cfide.orm.INamingStrategy { public string function getTableName(string tableName) { return Ucase(tableName); } public string function getColumnName(string columnName) { return Ucase(columnName); } }
  • 27. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 30 Q & A
  • 28. ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 31 Thank You ! - [email protected] - http://www.rupeshk.org

Editor's Notes

  • #6: -> Simple Property Mapping -> Over-riding the column Name -> Specifying the ormtype
  • #7: Show simple Mapping of Employee Show CRUD code of Employee Show non-persistent properties Show computed properties Show one-to-many relationship with array Show many-to-one Show CRUD on one-to-many relationship Show cascade operation Show logSQL Show ormreload Show one-to-many relationship with map Show one-to-one relationship Show many-to-many relationship
  • #18: CFTransaction tag is fully supported in ColdFusion-ORM Savepoint and rollback are supported Isolation-levels: Isolation level, which indicates which type of read can occur during the execution of concurrent SQL transactions. The possible read actions include dirty read, in which a second SQL transaction reads a row before the first SQL transaction executes a COMMIT; non-repeatable read, in which a SQL transaction reads a row and then a second SQL transaction modifies or deletes the row and executes a COMMIT; and phantom, in which a SQL transaction reads rows that meet search criteria, a second SQL transaction then generates at least one row that meets the first transaction's search criteria, and then the first transaction repeats the search, resulting in a different result set. read_uncommitted: Allows dirty read, non-repeatable read, and phantom read_committed: Allows non-repeatable read and phantom. Does not allow dirty read. repeatable_read: Allows phantom. Does not allow dirty read or non-repeatable read. serializable: Does not allow dirty read, non-repeatable read, or phantom.