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

About This Book
This comprehensive guide covers everything you need to know about ColdFusion ORM, from basic concepts to advanced techniques. Whether you're new to ORM or looking to deepen your understanding, this book provides practical examples and expert insights.
Complete Coverage
From basic ORM concepts to advanced Hibernate features, caching, and performance optimization.
Practical Examples
Real-world code examples and best practices for building robust ColdFusion applications.
Expert Author
Written by John Whish, a ColdFusion expert with over 10 years of development experience.
What People Are Saying
"Finished reading @aliaspooryorik's awesome book on #ColdFusion ORM. This is a must read for any CF developer."
– @elegant_chaos
"Essential reading for ORM newbies as well as the more experienced"
– Julian Halliwell
"It's more than worth the money, especially for people who are just starting to get serious about Hibernate"
– @MikeZ83
"Awesome book, makes this topic approachable, what a difference this makes thank you :)"
– Brett
"I'm about a quarter of the way through the book and so far it's fantastic. I've read bits and pieces about ORM before, but nothing that explains the basic concepts better than this."
– Gary Stanton
"Very good so far, and highly recommended to anyone wanting to know more"
– @CFWillSwain
Table of Contents
Preface
- Requirements
- What is ORM?
- What is Hibernate?
- Book Conventions
Chapter 1: Getting Started
- Configuring ORM in your Application
- Mapping Tables to Objects
- Allow ColdFusion to Modify the Database
- ORMReload
- Generating Database Schema
- Data Types and Precision
- Annotations
Chapter 2: ORM is CRUD
- Creating Records
- Disabling setters
- EntityNew
- EntitySave
- Reading data
- EntityLoad
- Reading Individual Records by ID
- EntityLoadByPK
- Loading Filtered Data
- Ordering Data
- Displaying data
- Updating Existing Data
- Deleting Records
Chapter 3: ORM Sessions
- What are ORM Sessions?
- The FlushAtRequestEnd Setting
- ORMFlush
- ORMClearSession
- Transactions
- Transactions in ColdFusion 9.0.0
Chapter 4: Relationships
- One-to-Many Relationships
- Many-to-One Relationships
- Many-to-Many Relationships
- One-to-One Relationships
- Generated Methods for Handling Relationships
- The Singularname attribute
- Adding & Removing Entities
- Choosing the Sort Order
- Handling Nulls
Chapter 5: Bi-Directional Associations
- Uni-Directional versus Bi-Directional
- Managing Relationships
- SQLIntegrityConstraintViolationException
- The inverse attribute
- Inverse and Many-to-Many
Chapter 6: Cascading
- Cascade Types
- Cascade None
- Cascade Delete Type
- Cascade Save-update Type
- Cascade All Type
- Cascade Delete-orphan Type
- Cascade All-delete-orphan Type
Chapter 7: HQL
- Getting Started With HQL
- Using a Where Clause
- Named Parameters
- Positional Parameters
- Nicer Looking HQL
- Using Operators in HQL
- Using Functions in HQL
- Relationships in HQL
- Selecting Properties
Chapter 8: Debugging
- Logging with ColdFusion Builder's Console View
- Running ColdFusion from a Console
- Viewing parameter values
- Logging to a File
- Viewing HQL Statements in Inline Debugging
- Getting HQL using Hibernate Statistics
Chapter 9: Computed Properties
- Using Formulas
- EntityReload
- Where Filter
Chapter 10: Event Handlers
- The Global Event Handler
- Entity Event Handlers
- Event Handler Methods
- Practical Examples
Chapter 11: Improving Performance
- Paging
- Maxresults
- Offset
- Lazy Loading
- The n+1 Selects Problem
- Fetch="join"
- Fetch with HQL
- Batch Fetching
- ORM Settings
Chapter 12: Caching
- First-Level Cache
- Second-Level Cache
- What's Cached?
- Caching Associated Entities
- Managing the cache
- ORMEvictEntity
- ORMEvictCollection
- ORMEvictQueries
- Bulk Operations
- Choosing the Cache Provider
Chapter 13: Validation
- Client-side Validation
- Server-side Validation
- ORM Validation
- Validation Framework Integration
Chapter 14: Advanced Mapping
- DataTypes and Precision
- The ormtype attribute
- Specifying Length, Nullable and more
- The column attribute
- Dbdefault attribute
- Length attribute
- Notnull attribute
- Precision attribute
- Scale attribute
- Sqltype attribute
- Unique attribute
- Uniquekey attribute
- Naming Strategy
- In-Built Naming Strategies
- Using Your Own Naming Strategy
Chapter 15: Schema Generation Revisited
- Advanced Schema Generation
- Inheritance Mapping
- One Table Per Persistent Entity
- One Table Per Persistent CFC With Discriminator
- One Table per Hierarchy
- HQL and Inheritance
- Using Collections Instead of Arrays
- Getting an Entity from a Collection
- The Inverse Attribute
Chapter 16: Tips, Tricks & Gotchas
- Tips
- Populate Using the EntityNew Constructor
- HQL IN Clause
- Refactoring to ORM with EntityToQuery
- Detecting Changes
- Multiple Datasources
- Non Persisted Properties
- Entities with the same name
- Tricks
- Hibernate Statistics
- Gotchas
- Constructor Arguments
- Detached Entities
- WriteDump causes ColdFusion to Crash
- Cached MetaData
- Generated Has Methods and Non-Persisted Entities
Appendix
- Quick Mapping Reference
- Relationships
- Setting up an Apache Derby Database
- References
- Documentation
- ColdFusion ORM Documentation
- Hibernate Documentation
- Publications
- Articles
- Hat Tips
- Where Next?
- And Finally…