| foreword to the revised edition | | xix | |
| foreword to the first edition | | xxi | |
| preface to the revised edition | | xxiii | |
| preface to the first edition | | xxv | |
| acknowledgments | | xxviii | |
| about this book | | xxix | |
| about the cover illustration | | xxxiii | |
| PART 1 GETTING STARTED WITH HIBERNATE AND EJB 3.0 |
| | 1 | |
| Understanding object/relational persistence |
| | 3 | |
| | 5 | |
| | 5 | |
| | 6 | |
| | 7 | |
| Persistence in object-oriented applications |
| | 8 | |
| | 10 | |
| The problem of granularity |
| | 12 | |
| | 13 | |
| | 14 | |
| Problems relating to associations |
| | 16 | |
| The problem of data navigation |
| | 18 | |
| | 19 | |
| Persistence layers and alternatives |
| | 20 | |
| | 20 | |
| Hand-coding a persistence layer with SQL/JDBC |
| | 22 | |
| | 23 | |
| Object-oriented database systems |
| | 23 | |
| | 24 | |
| Object/relational mapping |
| | 24 | |
| | 25 | |
| | 27 | |
| | 28 | |
| Introducing Hibernate, EJB3, and JPA |
| | 31 | |
| | 35 | |
| | 37 | |
| Starting a Hibernate project |
| | 38 | |
| Selecting a development process |
| | 39 | |
| | 41 | |
| Hibernate configuration and startup |
| | 49 | |
| Running and testing the application |
| | 60 | |
| Starting a Java Persistence project |
| | 68 | |
| Using Hibernate Annotations |
| | 68 | |
| Using Hibernate Entity Manager |
| | 72 | |
| Introducing EJB components |
| | 79 | |
| Switching to Hibernate interfaces |
| | 86 | |
| Reverse engineering a legacy database |
| | 88 | |
| Creating a database configuration |
| | 89 | |
| Customizing reverse engineering |
| | 90 | |
| Generating Java source code |
| | 92 | |
| Integration with Java EE services |
| | 96 | |
| | 97 | |
| JNDI-bound SessionFactory |
| | 101 | |
| | 103 | |
| | 104 | |
| Domain models and metadata |
| | 105 | |
| The CaveatEmptor application |
| | 106 | |
| Analyzing the business domain |
| | 107 | |
| The CaveatEmptor domain model |
| | 108 | |
| Implementing the domain model |
| | 110 | |
| Addressing leakage of concerns |
| | 111 | |
| Transparent and automated persistence |
| | 112 | |
| Writing POJOs and persistent entity classes |
| | 113 | |
| Implementing POJO associations |
| | 116 | |
| Adding logic to accessor methods |
| | 120 | |
| Object/relational mapping metadata |
| | 123 | |
| | 123 | |
| Annotation-based metadata |
| | 125 | |
| | 131 | |
| | 133 | |
| Manipulating metadata at runtime |
| | 138 | |
| Alternative entity representation |
| | 140 | |
| Creating dynamic applications |
| | 141 | |
| | 148 | |
| | 152 | |
| PART 2 MAPPING CONCEPTS AND STRATEGIES |
| | 155 | |
| Mapping persistent classes |
| | 157 | |
| Understanding entities and value types |
| | 158 | |
| Fine-grained domain models |
| | 158 | |
| | 159 | |
| Identifying entities and value types |
| | 160 | |
| Mapping entities with identity |
| | 161 | |
| Understanding Java identity and equality |
| | 162 | |
| Handling database identity |
| | 162 | |
| | 165 | |
| | 171 | |
| | 172 | |
| Making an entity immutable |
| | 173 | |
| Naming entities for querying |
| | 173 | |
| | 174 | |
| | 175 | |
| Implementing naming conventions |
| | 175 | |
| Fine-grained models and mappings |
| | 177 | |
| | 177 | |
| | 184 | |
| | 189 | |
| Inheritance and custom types |
| | 191 | |
| Mapping class inheritance |
| | 192 | |
| Table per concrete class with implicit polymorphism |
| | 192 | |
| Table per concrete class with unions |
| | 195 | |
| Table per class hierarchy |
| | 199 | |
| | 203 | |
| Mixing inheritance strategies |
| | 207 | |
| | 210 | |
| The Hibernate type system |
| | 212 | |
| Recapitulating entity and value types |
| | 212 | |
| | 214 | |
| | 219 | |
| Creating custom mapping types |
| | 220 | |
| Considering custom mapping types |
| | 221 | |
| | 222 | |
| The case for custom mapping types |
| | 223 | |
| | 224 | |
| Creating a CompositeUserType |
| | 228 | |
| Parameterizing custom types |
| | 230 | |
| | 233 | |
| | 239 | |
| Mapping collections and entity associations |
| | 240 | |
| Sets, bags, lists, and maps of value types |
| | 241 | |
| Selecting a collection interface |
| | 241 | |
| | 243 | |
| Mapping an identifier bag |
| | 244 | |
| | 246 | |
| | 247 | |
| Sorted and ordered collections |
| | 248 | |
| Collections of components |
| | 251 | |
| Writing the component class |
| | 252 | |
| | 252 | |
| Enabling bidirectional navigation |
| | 253 | |
| Avoiding not-null columns |
| | 254 | |
| Mapping collections with annotations |
| | 256 | |
| | 256 | |
| Sorted and ordered collections |
| | 257 | |
| Mapping a collection of embedded objects |
| | 258 | |
| Mapping a parent/children relationship |
| | 260 | |
| | 261 | |
| The simplest possible association |
| | 261 | |
| Making the association bidirectional |
| | 264 | |
| | 267 | |
| | 275 | |
| Advanced entity association mappings |
| | 277 | |
| Single-valued entity associations |
| | 278 | |
| Shared primary key associations |
| | 279 | |
| One-to-one foreign key associations |
| | 282 | |
| Mapping with a join table |
| | 285 | |
| Many-valued entity associations |
| | 290 | |
| | 290 | |
| Many-to-many associations |
| | 297 | |
| Adding columns to join tables |
| | 303 | |
| | 310 | |
| | 313 | |
| Polymorphic many-to-one associations |
| | 313 | |
| | 315 | |
| Polymorphic associations to unions |
| | 316 | |
| Polymorphic table per concrete class |
| | 319 | |
| | 321 | |
| Legacy databases and custom SQL |
| | 322 | |
| Integrating legacy databases |
| | 323 | |
| | 324 | |
| Arbitrary join conditions with formulas |
| | 337 | |
| | 342 | |
| | 346 | |
| | 350 | |
| Writing custom CRUD statements |
| | 351 | |
| Integrating stored procedures and functions |
| | 356 | |
| | 364 | |
| Custom SQL names and datatypes |
| | 365 | |
| Ensuring data consistency |
| | 367 | |
| Adding domains and column constraints |
| | 369 | |
| | 370 | |
| | 373 | |
| | 375 | |
| | 376 | |
| | 378 | |
| PART 3 CONVERSATIONAL OBJECT PROCESSING |
| | 381 | |
| | 383 | |
| The persistence lifecycle |
| | 384 | |
| | 385 | |
| | 388 | |
| Object identity and equality |
| | 391 | |
| Introducing conversations |
| | 391 | |
| The scope of object identity |
| | 393 | |
| The identity of detached objects |
| | 394 | |
| Extending a persistence context |
| | 400 | |
| | 401 | |
| Storing and loading objects |
| | 402 | |
| Working with detached objects |
| | 408 | |
| Managing the persistence context |
| | 414 | |
| | 417 | |
| Storing and loading objects |
| | 417 | |
| Working with detached entity instances |
| | 423 | |
| Using Java Persistence in EJB components |
| | 426 | |
| Injecting an EntityManager |
| | 426 | |
| Looking up an EntityManager |
| | 429 | |
| Accessing an EntityManagerFactory |
| | 429 | |
| | 431 | |
| Transactions and concurrency |
| | 433 | |
| | 434 | |
| Database and system transactions |
| | 435 | |
| Transactions in a Hibernate application |
| | 437 | |
| Transactions with Java Persistence |
| | 449 | |
| Controlling concurrent access |
| | 453 | |
| Understanding database-level concurrency |
| | 453 | |
| Optimistic concurrency control |
| | 458 | |
| Obtaining additional isolation guarantees |
| | 465 | |
| Nontransactional data access |
| | 469 | |
| Debunking autocommit myths |
| | 470 | |
| Working nontransactionally with Hibernate |
| | 471 | |
| Optional transactions with JTA |
| | 473 | |
| | 474 | |
| Implementing conversations |
| | 476 | |
| Propagating the Hibernate Session |
| | 477 | |
| The use case for Session propagation |
| | 478 | |
| Propagation through thread-local |
| | 480 | |
| | 482 | |
| | 483 | |
| Conversations with Hibernate |
| | 485 | |
| Providing conversational guarantees |
| | 485 | |
| Conversations with detached objects |
| | 486 | |
| Extending a Session for a conversation |
| | 489 | |
| | 497 | |
| Persistence context propagation in Java SE |
| | 498 | |
| Merging detached objects in conversations |
| | 499 | |
| Extending the persistence context in Java SE |
| | 501 | |
| Conversations with EJB 3.0 |
| | 506 | |
| Context propagation with EJBs |
| | 506 | |
| Extended persistence contexts with EJBs |
| | 510 | |
| | 515 | |
| Modifying objects efficiently |
| | 517 | |
| | 518 | |
| Persistence by reachability |
| | 519 | |
| Applying cascading to associations |
| | 520 | |
| Working with transitive state |
| | 524 | |
| Transitive associations with JPA |
| | 531 | |
| Bulk and batch operations |
| | 532 | |
| Bulk statements with HQL and JPA QL |
| | 533 | |
| | 537 | |
| Using a stateless Session |
| | 539 | |
| Data filtering and interception |
| | 540 | |
| | 541 | |
| Intercepting Hibernate events |
| | 546 | |
| | 553 | |
| Entity listeners and callbacks |
| | 556 | |
| | 558 | |
| Optimizing fetching and caching |
| | 559 | |
| Defining the global fetch plan |
| | 560 | |
| The object-retrieval options |
| | 560 | |
| The lazy default fetch plan |
| | 564 | |
| | 564 | |
| Disabling proxy generation |
| | 567 | |
| Eager loading of associations and collections |
| | 568 | |
| Lazy loading with interception |
| | 571 | |
| Selecting a fetch strategy |
| | 573 | |
| Prefetching data in batches |
| | 574 | |
| Prefetching collections with subselects |
| | 577 | |
| Eager fetching with joins |
| | 578 | |
| Optimizing fetching for secondary tables |
| | 581 | |
| | 584 | |
| | 592 | |
| Caching strategies and scopes |
| | 593 | |
| The Hibernate cache architecture |
| | 597 | |
| | 602 | |
| Selecting a concurrency control strategy |
| | 602 | |
| Understanding cache regions |
| | 604 | |
| Setting up a local cache provider |
| | 605 | |
| Setting up a replicated cache |
| | 606 | |
| Controlling the second-level cache |
| | 611 | |
| | 612 | |
| Querying with HQL and JPA QL |
| | 614 | |
| Creating and running queries |
| | 615 | |
| | 616 | |
| | 625 | |
| | 629 | |
| Basic HQL and JPA QL queries |
| | 633 | |
| | 633 | |
| | 635 | |
| | 641 | |
| Joins, reporting queries, and subselects |
| | 643 | |
| Joining relations and associations |
| | 643 | |
| | 655 | |
| | 659 | |
| | 662 | |
| | 663 | |
| Querying with criteria and example |
| | 664 | |
| | 665 | |
| Joins and dynamic fetching |
| | 670 | |
| Projection and report queries |
| | 676 | |
| | 680 | |
| | 683 | |
| Automatic resultset handling |
| | 683 | |
| | 684 | |
| Native SQL in Java Persistence |
| | 686 | |
| | 688 | |
| | 691 | |
| Enabling the query result cache |
| | 691 | |
| Understanding the query cache |
| | 692 | |
| When to use the query cache |
| | 693 | |
| Natural identifier cache lookups |
| | 693 | |
| | 695 | |
| Creating and testing layered applications |
| | 697 | |
| Hibernate in a web application |
| | 698 | |
| | 698 | |
| | 699 | |
| The Open Session in View pattern |
| | 701 | |
| Designing smart domain models |
| | 705 | |
| Creating a persistence layer |
| | 708 | |
| A generic data-access object pattern |
| | 709 | |
| Implementing the generic CRUD interface |
| | 711 | |
| | 713 | |
| Using data-access objects |
| | 715 | |
| Introducing the Command pattern |
| | 718 | |
| | 719 | |
| Executing command objects |
| | 721 | |
| Variations of the Command pattern |
| | 723 | |
| Designing applications with EJB 3.0 |
| | 725 | |
| Implementing a conversation with stateful beans |
| | 725 | |
| | 727 | |
| Utilizing dependency injection |
| | 728 | |
| | 730 | |
| Understanding different kinds of tests |
| | 731 | |
| | 732 | |
| Testing the persistence layer |
| | 736 | |
| Considering performance benchmarks |
| | 744 | |
| | 746 | |
| | 747 | |
| The Java EE 5.0 programming model |
| | 748 | |
| Considering JavaServer Faces |
| | 749 | |
| | 751 | |
| Writing a web application with JSF and EJB 3.0 |
| | 752 | |
| Analyzing the application |
| | 762 | |
| Improving the application with Seam |
| | 765 | |
| | 766 | |
| Binding pages to stateful Seam components |
| | 767 | |
| Analyzing the Seam application |
| | 773 | |
| Understanding contextual components |
| | 779 | |
| | 779 | |
| | 781 | |
| Aliasing contextual variables |
| | 784 | |
| Completing the login/logout feature |
| | 786 | |
| | 789 | |
| Introducing Hibernate Validator |
| | 790 | |
| Creating the registration page |
| | 791 | |
| Internationalization with Seam |
| | 799 | |
| Simplifying persistence with Seam |
| | 803 | |
| Implementing a conversation |
| | 804 | |
| Letting Seam manage the persistence context |
| | 811 | |
| | 816 | |
| appendix A SQL fundamentals | | 818 | |
| appendix B Mapping quick reference | | 822 | |
| references | | 824 | |
| index | | 825 | |