Foreword | p. xv |
About the Authors | p. xvii |
About the Technical Reviewers | p. xix |
Acknowledgments | p. xxi |
Preface | p. xxiii |
Introduction | p. 1 |
Java Support for Persistence | p. 2 |
JDBC | p. 2 |
Enterprise JavaBeans | p. 2 |
Java Data Objects | p. 3 |
Why Another Standard? | p. 4 |
Object-Relational Mapping | p. 5 |
The Impedance Mismatch | p. 6 |
The Java Persistence API | p. 12 |
History of the Specification | p. 12 |
Overview | p. 13 |
Summary | p. 15 |
Getting Started | p. 17 |
Entity Overview | p. 17 |
Persistability | p. 17 |
Identity | p. 18 |
Transactionality | p. 18 |
Granularity | p. 18 |
Entity Metadata | p. 19 |
Annotations | p. 19 |
XML | p. 19 |
Configuration by Exception | p. 20 |
Creating an Entity | p. 21 |
Automatic State Mapping | p. 22 |
Entity Manager | p. 23 |
Obtaining an Entity Manager | p. 24 |
Persisting an Entity | p. 25 |
Finding an Entity | p. 26 |
Removing an Entity | p. 27 |
Updating an Entity | p. 28 |
Transactions | p. 28 |
Queries | p. 29 |
Putting It All Together | p. 30 |
Packaging It Up | p. 33 |
Persistence Unit | p. 33 |
Persistence Archive | p. 34 |
Summary | p. 34 |
Enterprise Applications | p. 35 |
Application Component Models | p. 35 |
Session Beans | p. 37 |
Stateless Session Beans | p. 37 |
Stateful Session Beans | p. 41 |
Message-Driven Beans | p. 44 |
Defining a Message-Driven Bean | p. 44 |
Servlets | p. 45 |
Dependency Management | p. 46 |
Dependency Lookup | p. 47 |
Dependency Injection | p. 49 |
Declaring Dependencies | p. 51 |
Transaction Management | p. 54 |
Transaction Review | p. 54 |
Enterprise Transactions in Java | p. 55 |
Using Java EE Components | p. 60 |
Using a Stateless Session Bean | p. 61 |
Using a Stateful Session Bean | p. 61 |
Using a Message-Driven Bean | p. 63 |
Adding the Entity Manager | p. 64 |
Putting It All Together | p. 65 |
Defining the Component | p. 65 |
Defining the User Interface | p. 67 |
Packaging It Up | p. 68 |
Summary | p. 68 |
Object-Relational Mapping | p. 71 |
Persistence Annotations | p. 71 |
Accessing Entity State | p. 72 |
Field Access | p. 72 |
Property Access | p. 73 |
Mapping to a Table | p. 74 |
Mapping Simple Types | p. 75 |
Column Mappings | p. 76 |
Lazy Fetching | p. 77 |
Large Objects | p. 79 |
Enumerated Types | p. 79 |
Temporal Types | p. 81 |
Transient State | p. 82 |
Mapping the Primary Key | p. 83 |
Identifier Generation | p. 83 |
Relationships | p. 88 |
Relationship Concepts | p. 89 |
Mappings Overview | p. 92 |
Single-Valued Associations | p. 92 |
Collection-Valued Associations | p. 99 |
Lazy Relationships | p. 108 |
Summary | p. 108 |
Entity Manager | p. 111 |
Persistence Contexts | p. 111 |
Entity Managers | p. 112 |
Container-Managed Entity Managers | p. 112 |
Application-Managed Entity Managers | p. 117 |
Transaction Management | p. 119 |
JTA Transaction Management | p. 119 |
Resource-Local Transactions | p. 128 |
Transaction Rollback and Entity State | p. 131 |
Choosing an Entity Manager | p. 131 |
Entity Manager Operations | p. 132 |
Persisting an Entity | p. 132 |
Finding an Entity | p. 133 |
Removing an Entity | p. 135 |
Cascading Operations | p. 136 |
Clearing the Persistence Context | p. 138 |
Synchronization with the Database | p. 139 |
Detachment and Merging | p. 141 |
Detachment | p. 142 |
Merging Detached Entities | p. 143 |
Working with Detached Entities | p. 147 |
Summary | p. 161 |
Using Queries | p. 163 |
Java Persistence QL | p. 163 |
Getting Started | p. 164 |
Filtering Results | p. 165 |
Projecting Results | p. 165 |
Joins Between Entities | p. 165 |
Aggregate Queries | p. 166 |
Query Parameters | p. 166 |
Defining Queries | p. 167 |
Dynamic Query Definition | p. 167 |
Named Query Definition | p. 170 |
Parameter Types | p. 171 |
Executing Queries | p. 173 |
Working with Query Results | p. 175 |
Query Paging | p. 178 |
Queries and Uncommitted Changes | p. 180 |
Bulk Update and Delete | p. 183 |
Using Bulk Update and Delete | p. 183 |
Bulk Delete and Relationships | p. 186 |
Query Hints | p. 187 |
Query Best Practices | p. 188 |
Named Queries | p. 188 |
Report Queries | p. 188 |
Query Hints | p. 189 |
Stateless Session Beans | p. 189 |
Bulk Update and Delete | p. 189 |
Provider Differences | p. 189 |
Summary | p. 190 |
Query Language | p. 191 |
Introduction | p. 191 |
Terminology | p. 192 |
Example Data Model | p. 192 |
Example Application | p. 193 |
Select Queries | p. 195 |
The SELECT Clause | p. 197 |
The FROM Clause | p. 200 |
The WHERE Clause | p. 206 |
The ORDER BY Clause | p. 214 |
Aggregate Queries | p. 214 |
Aggregate Functions | p. 216 |
The GROUP BY Clause | p. 216 |
The HAVING Clause | p. 217 |
Update Queries | p. 218 |
Delete Queries | p. 218 |
Summary | p. 219 |
Advanced Object-Relational Mapping | p. 221 |
Embedded Objects | p. 221 |
Sharing Embedded Object Classes | p. 224 |
Compound Primary Keys | p. 225 |
Id Class | p. 226 |
Embedded Id Class | p. 228 |
Advanced Mapping Elements | p. 229 |
Read-Only Mappings | p. 229 |
Optionality | p. 230 |
Advanced Relationships | p. 231 |
Compound Join Columns | p. 231 |
Identifiers That Include a Relationship | p. 233 |
Mapping Relationship State | p. 235 |
Multiple Tables | p. 237 |
Inheritance | p. 241 |
Class Hierarchies | p. 241 |
Inheritance Models | p. 246 |
Mixed Inheritance | p. 253 |
Summary | p. 255 |
Advanced Topics | p. 257 |
SQL Queries | p. 257 |
Native Queries vs. JDBC | p. 258 |
Defining and Executing SQL Queries | p. 260 |
SQL Result Set Mapping | p. 262 |
Parameter Binding | p. 268 |
Lifecycle Callbacks | p. 268 |
Lifecycle Events | p. 269 |
Callback Methods | p. 270 |
Entity Listeners | p. 271 |
Inheritance and Lifecycle Events | p. 274 |
Concurrency | p. 279 |
Entity Operations | p. 279 |
Entity Access | p. 279 |
Refreshing Entity State | p. 279 |
Locking | p. 282 |
Optimistic Locking | p. 282 |
Versioning | p. 284 |
Additional Locking Strategies | p. 285 |
Recovering from Optimistic Failures | p. 290 |
Schema Generation | p. 293 |
Unique Constraints | p. 293 |
Null Constraints | p. 294 |
String-Based Columns | p. 295 |
Floating Point Columns | p. 295 |
Defining the Column | p. 296 |
Summary | p. 297 |
XML Mapping Files | p. 299 |
The Metadata Puzzle | p. 300 |
The Mapping File | p. 301 |
Disabling Annotations | p. 301 |
Persistence Unit Defaults | p. 303 |
Mapping File Defaults | p. 306 |
Queries and Generators | p. 308 |
Managed Classes and Mappings | p. 312 |
Summary | p. 333 |
Packaging and Deployment | p. 335 |
Configuring Persistence Units | p. 335 |
Persistence Unit Name | p. 336 |
Transaction Type | p. 336 |
Persistence Provider | p. 337 |
Data Source | p. 337 |
Mapping Files | p. 338 |
Managed Classes | p. 339 |
Adding Vendor Properties | p. 341 |
Building and Deploying | p. 342 |
Deployment Classpath | p. 342 |
Packaging Options | p. 343 |
Persistence Unit Scope | p. 347 |
Outside the Server | p. 348 |
Configuring the Persistence Unit | p. 348 |
Specifying Properties at Runtime | p. 350 |
System Classpath | p. 351 |
Summary | p. 351 |
Testing | p. 353 |
Testing Enterprise Applications | p. 353 |
Terminology | p. 354 |
Testing Outside the Server | p. 355 |
Test Frameworks | p. 356 |
Unit Testing | p. 357 |
Testing Entities | p. 357 |
Testing Entities in Components | p. 359 |
The Entity Manager in Unit Tests | p. 361 |
Integration Testing | p. 364 |
Using the Entity Manager | p. 364 |
Components and Persistence | p. 370 |
Best Practices | p. 383 |
Summary | p. 384 |
Table of Contents provided by Ingram. All Rights Reserved. |