ColdFusion ORM Book Cover

ColdFusion ORM

A guide to developing applications using ColdFusion ORM

This is a book that every ColdFusion programmer should have on his or her shelf. I know I am glad to have it on mine.
– Bob Silverberg

Get the eBook $13.00

Buy from gumroad
PDF, EPUB and PRC formats included

Get the eBook £8.00

PDF, EPUB and PRC formats included
Please note there may be a delay before I email you

Get the Paperback £16.50

Support independent publishing: Buy this book on Lulu.

Table of Contents

Table of Contents3
Acknowledgements 9
Preface 10
Requirements 10
What is ORM? 11
What is Hibernate?11
Book Conventions 11
Chapter 1 : Getting Started 13
Configuring ORM in your Application 13
Mapping Tables to Objects14
Allow ColdFusion to Modify the Database17
Generating Database Schema 18
Data Types and Precision19
Annotations 21
Chapter 2 : ORM is CRUD 23
Creating Records 23
Disabling setters 24
Reading data 25
Reading Individual Records by ID 27
Loading Filtered Data 28
Ordering Data29
Displaying data29
Updating Existing Data30
Deleting Records31
Chapter 3 : ORM Sessions 33
What are ORM Sessions?33
The FlushAtRequestEnd Setting 33
ORMFlush 35
Transactions in ColdFusion 9.0.0 40
Chapter 4 : Relationships41
One-to-Many Relationships41
Generated Methods for Handling Relationships 42
The Singularname attribute 44
Adding Entities to a One-to-Many Relationship 45
Removing Entities from a One-to-Many Relationship51
Choosing the Sort Order52
Many-to-One Relationships53
Many-to-Many Relationships55
One-to-One Relationships58
Handling Nulls 60
Chapter 5 : Bi-Directional Associations 63
Uni-Directional versus Bi-Directional63
Managing Relationships 63
The inverse attribute68
Inverse and Many-to-Many70
Chapter 6 : Cascading 73
Cascade Types 74
Cascade None74
Cascade Delete Type 75
Cascade Save-update Type 75
Cascade All Type77
Cascade Delete-orphan Type77
Cascade All-delete-orphan Type 78
Chapter 7 : HQL79
Getting Started With HQL79
Using a Where Clause 80
Named Parameters 81
Positional Parameters 81
Nicer Looking HQL82
Using Operators in HQL 82
Using Functions in HQL83
Relationships in HQL 84
Selecting Properties 88
Chapter 8 : Debugging 91
Logging with ColdFusion Builder’s Console View 91
Running ColdFusion from a Console 92
Viewing parameter values 93
Logging to a File94
Viewing HQL Statements in Inline Debugging 95
Getting HQL using Hibernate Statistics96
Chapter 9 : Computed Properties99
Using Formulas 99
EntityReload 101
Where Filter104
Chapter 10 : Event Handlers 107
The Global Event Handler 109
Chapter 11 : Improving Performance113
Paging 113
Maxresults 113
Offset 113
Lazy Loading 114
The n+1 Selects Problem117
Fetch="join" 118
Fetch with HQL120
Batch Fetching 121
ORM Settings 123
Chapter 12 : Caching 126
First-Level Cache 126
Second-Level Cache 126
What’s Cached? 128
Caching Associated Entities129
Managing the cache 130
ORMEvictQueries 131
Bulk Operations132
Choosing the Cache Provider 132
Chapter 13 : Validation 134
Chapter 14 : Advanced Mapping 137
Mapping Inheritance137
One Table Per Persistent Entity 138
One Table Per Persistent CFC With Discriminator142
One Table per Hierarchy 144
HQL and Inheritance146
Using Collections Instead of Arrays 146
Getting an Entity from a Collection 153
The Inverse Attribute 153
Chapter 15 : Schema Generation Revisited 155
DataTypes and Precision 155
The ormtype attribute155
Specifying Length, Nullable and more156
The column attribute 156
Dbdefault attribute 157
Length attribute157
Notnull attribute157
Precision attribute 158
Scale attribute158
Sqltype attribute158
Unique attribute 158
Uniquekey attribute158
Naming Strategy158
In-Built Naming Strategies 158
Using Your Own Naming Strategy160
Chapter 16 : Tips, Tricks & Gotchas 162
Populate Using the EntityNew Constructor162
HQL IN Clause162
Refactoring to ORM with EntityToQuery163
Detecting Changes 163
Multiple Datasources 164
Non Persisted Properties164
Entities with the same name165
Hibernate Statistics166
Gotchas 169
Constructor Arguments169
Detached Entities170
WriteDump causes ColdFusion to Crash171
Cached MetaData172
Generated Has Methods and Non-Persisted Entities 172
Quick Mapping Reference174
Relationships 174
Setting up an Apache Derby Database 175
Documentation 176
ColdFusion ORM Documentation 176
Hibernate Documentation 176
Publications 176
Articles 176
Hat Tips 176
Where Next? 177
And Finally… 178
© John Whish 2011 - 2013