Foreword | 2 |
---|
Table of Contents | 3 |
---|
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 Objects | 14 |
Allow ColdFusion to Modify the Database | 17 |
ORMReload | 18 |
Generating Database Schema | 18 |
Data Types and Precision | 19 |
Annotations | 21 |
Chapter 2 : ORM is CRUD | 23 |
---|
Creating Records | 23 |
Disabling setters | 24 |
EntityNew | 24 |
EntitySave | 25 |
Reading data | 25 |
EntityLoad | 25 |
Reading Individual Records by ID | 27 |
EntityLoadByPK | 28 |
Loading Filtered Data | 28 |
Ordering Data | 29 |
Displaying data | 29 |
Updating Existing Data | 30 |
Deleting Records | 31 |
Chapter 3 : ORM Sessions | 33 |
---|
What are ORM Sessions? | 33 |
The FlushAtRequestEnd Setting | 33 |
ORMFlush | 35 |
ORMClearSession | 36 |
Transactions | 38 |
Transactions in ColdFusion 9.0.0 | 40 |
Chapter 4 : Relationships | 41 |
---|
One-to-Many Relationships | 41 |
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 Relationship | 51 |
Choosing the Sort Order | 52 |
Many-to-One Relationships | 53 |
Many-to-Many Relationships | 55 |
One-to-One Relationships | 58 |
Handling Nulls | 60 |
Chapter 5 : Bi-Directional Associations | 63 |
---|
Uni-Directional versus Bi-Directional | 63 |
Managing Relationships | 63 |
SQLIntegrityConstraintViolationException | 67 |
The inverse attribute | 68 |
Inverse and Many-to-Many | 70 |
Chapter 6 : Cascading | 73 |
---|
Cascade Types | 74 |
Cascade None | 74 |
Cascade Delete Type | 75 |
Cascade Save-update Type | 75 |
Cascade All Type | 77 |
Cascade Delete-orphan Type | 77 |
Cascade All-delete-orphan Type | 78 |
Chapter 7 : HQL | 79 |
---|
Getting Started With HQL | 79 |
Using a Where Clause | 80 |
Named Parameters | 81 |
Positional Parameters | 81 |
Nicer Looking HQL | 82 |
Using Operators in HQL | 82 |
Using Functions in HQL | 83 |
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 File | 94 |
Viewing HQL Statements in Inline Debugging | 95 |
Getting HQL using Hibernate Statistics | 96 |
Chapter 9 : Computed Properties | 99 |
---|
Using Formulas | 99 |
EntityReload | 101 |
Where Filter | 104 |
Chapter 10 : Event Handlers | 107 |
---|
The Global Event Handler | 109 |
Chapter 11 : Improving Performance | 113 |
---|
Paging | 113 |
Maxresults | 113 |
Offset | 113 |
Lazy Loading | 114 |
The n+1 Selects Problem | 117 |
Fetch="join" | 118 |
Fetch with HQL | 120 |
Batch Fetching | 121 |
ORM Settings | 123 |
Chapter 12 : Caching | 126 |
---|
First-Level Cache | 126 |
Second-Level Cache | 126 |
What’s Cached? | 128 |
Caching Associated Entities | 129 |
Managing the cache | 130 |
ORMEvictEntity | 130 |
ORMEvictCollection | 131 |
ORMEvictQueries | 131 |
Bulk Operations | 132 |
Choosing the Cache Provider | 132 |
Chapter 13 : Validation | 134 |
---|
Chapter 14 : Advanced Mapping | 137 |
---|
Mapping Inheritance | 137 |
One Table Per Persistent Entity | 138 |
One Table Per Persistent CFC With Discriminator | 142 |
One Table per Hierarchy | 144 |
HQL and Inheritance | 146 |
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 attribute | 155 |
Specifying Length, Nullable and more | 156 |
The column attribute | 156 |
Dbdefault attribute | 157 |
Length attribute | 157 |
Notnull attribute | 157 |
Precision attribute | 158 |
Scale attribute | 158 |
Sqltype attribute | 158 |
Unique attribute | 158 |
Uniquekey attribute | 158 |
Naming Strategy | 158 |
In-Built Naming Strategies | 158 |
Using Your Own Naming Strategy | 160 |
Chapter 16 : Tips, Tricks & Gotchas | 162 |
---|
Tips | 162 |
Populate Using the EntityNew Constructor | 162 |
HQL IN Clause | 162 |
Refactoring to ORM with EntityToQuery | 163 |
Detecting Changes | 163 |
Multiple Datasources | 164 |
Non Persisted Properties | 164 |
Entities with the same name | 165 |
Tricks | 166 |
Hibernate Statistics | 166 |
Gotchas | 169 |
Constructor Arguments | 169 |
Detached Entities | 170 |
WriteDump causes ColdFusion to Crash | 171 |
Cached MetaData | 172 |
Generated Has Methods and Non-Persisted Entities | 172 |
Appendix | 174 |
Quick Mapping Reference | 174 |
Relationships | 174 |
Setting up an Apache Derby Database | 175 |
References | 176 |
Documentation | 176 |
ColdFusion ORM Documentation | 176 |
Hibernate Documentation | 176 |
Publications | 176 |
Articles | 176 |
Hat Tips | 176 |
Where Next? | 177 |
And Finally… | 178 |