O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Beginning Hibernate: From Novice to Professional

Book Description

Beginning Hibernate is ideal if you're experienced in Java with databases (the traditional, or connected, approach), but are new to open source lightweight Hibernate—the most popular de facto object-relational mapping and database-oriented application development framework. This book packs in information about the release of the Hibernate 3.2.x persistence layer and provides a clear introduction to the current standard for object-relational persistence in Java.

Experienced author Dave Minter and contributor Jeff Linwood provide more in-depth examples than any other books for Hibernate beginners. The authors also present material in a lively, example-based mannernot in a dry, theoretical, hard-to-read fashion. And since the book keeps its focus on Hibernate without wasting time on nonessential third-party tools, you'll be able to immediately start building transaction-based engines and applications.

Table of Contents

  1. Title Page
  2. Contents at a Glance
  3. Contents
  4. About the Authors
  5. About the Technical Reviewer
  6. Acknowledgments
  7. Introduction
    1. Who This Book Is For
    2. How This Book Is Structured
    3. Downloading the Code
    4. Contacting the Authors
  8. CHAPTER 1: An Introduction to Hibernate 3
    1. Plain Old Java Objects (POJOs)
    2. Origins of Hibernate and Object-Relational Mapping
    3. A Hibernate Hello World Example
    4. Mappings
    5. Database Generation
    6. The Relationship of Hibernate 3 with EJB 3.0
    7. Summary
  9. CHAPTER 2: Integrating and Configuring Hibernate
    1. The Steps Needed to Integrate and Configure Hibernate
    2. Understanding Where Hibernate Fits in Your Java Application
    3. Deploying Hibernate
    4. Hibernate Configuration
    5. The Session Factory
    6. SQL Dialects
    7. Summary
  10. CHAPTER 3: Building a Simple Application
    1. Installing the Tools
    2. Creating a Hibernate Configuration File
    3. Running the Message Example
    4. Persisting Multiple Objects
    5. Creating Persistence Classes
    6. Creating the Object Mappings
    7. Creating the Tables
    8. Sessions
    9. Building DAOs
    10. The Example Client
    11. Summary
  11. CHAPTER 4: The Persistence Life Cycle
    1. Introduction to the Life Cycle
    2. Entities, Classes, and Names
    3. Identifiers
    4. Entities and Associations
    5. Saving Entities
    6. Object Equality and Identity
    7. Loading Entities
    8. Refreshing Entities
    9. Updating Entities
    10. Deleting Entities
    11. Cascading Operations
    12. Lazy Loading, Proxies, and Collection Wrappers
    13. Querying Objects
    14. Summary
  12. CHAPTER 5: An Overview of Mapping
    1. Why Mapping Cannot Be Automated
    2. Primary Keys
    3. Lazy Loading
    4. Associations
    5. Types of Mapping
    6. Other Information Represented in Mappings
    7. Summary
  13. CHAPTER 6: Mapping with Annotations
    1. Java 5 Features
    2. Creating Hibernate Mappings with Annotations
    3. Configuring the Annotated Classes
    4. Hibernate 3–Specific Persistence Annotations
    5. Using Ant with Annotation-Based Mappings
    6. Code Listings
    7. Summary
  14. CHAPTER 7: Creating Mappings with Hibernate XML Files
    1. Hibernate Types
    2. The Anatomy of a Mapping File
    3. Mapping Simple Classes
    4. Mapping Composition
    5. Mapping Other Associations
    6. Mapping Collections
    7. Mapping Inheritance Relationships
    8. More Exotic Mappings
    9. Summary
  15. CHAPTER 8: Using the Session
    1. Sessions
    2. Transactions and Locking
    3. Caching
    4. Threads
    5. Summary
  16. CHAPTER 9: Searches and Queries
    1. HQL
    2. Syntax Basics
    3. The First Example with HQL
    4. Logging the Underlying SQL
    5. The from Clause and Aliases
    6. The select Clause and Projection
    7. Using Restrictions with HQL
    8. Using Named Parameters
    9. Paging Through the Result Set
    10. Obtaining a Unique Result
    11. Sorting Results with the order by Clause
    12. Associations
    13. Bulk Updates and Deletes with HQL
    14. Named Queries for HQL and SQL
    15. Using Native SQL
    16. Summary
  17. CHAPTER 10: Advanced Queries Using Criteria
    1. Using the Criteria API
    2. Summary
  18. CHAPTER 11: Filtering the Results of Searches
    1. When to Use Filters
    2. Defining Filters
    3. Using Filters in Your Application
    4. A Basic Filtering Example
    5. Summary
  19. APPENDIX A: More Advanced Features
    1. EJB 3 and the EntityManager
    2. Managed Versioning and Optimistic Locking
    3. XML Relational Persistence
    4. Maps
    5. Limitations of Hibernate
    6. Hand-Rolled SQL
    7. Invoking Stored Procedures
    8. Events
    9. Interceptors
    10. Overriding the Default Constructor
    11. Summary
  20. APPENDIX B: Hibernate Tools
    1. The Eclipse Plug-In
    2. The Ant Tasks
    3. Summary
  21. APPENDIX C: Hibernate and Spring
    1. Spring Libraries
    2. Configuring Hibernate from a Spring Application
    3. Using Hibernate in Your Spring Beans
    4. Declarative Transaction Management
    5. Managing the Session
    6. The Sample Configuration File
    7. Summary
  22. APPENDIX D: Upgrading from Hibernate 2
    1. Package and DTD Changes
    2. New Features and Support for Old Ones
    3. Changes to Tools and Libraries
    4. Changes with Java 5
    5. Summary
  23. Index