Just Hibernate

Book description

If you’re looking for a short, sweet, and simple introduction (or reintroduction) to Hibernate, this is the book you want. Through clear real-world examples, you’ll learn Hibernate and object-relational mapping from the ground up, starting with the basics. Then you’ll dive into the framework’s moving parts to understand how they work in action.

Storing Java objects in relational databases is usually a challenging and complex task for any Java developer, experienced or not. This book, like others in the Just series, delivers a concise, example-driven tutorial for Java beginners. You’ll gain enough knowledge and confidence to start working on real-world projects with Hibernate.

  • Compare how JDBC and Hibernate work with object persistence
  • Learn how annotations are used to create Hibernate applications
  • Understand how to persist and retrieve Java data structures
  • Focus on the fundamentals of associations and their mappings
  • Delve into advanced concepts such as caching, inheritance, and types
  • Walk through the Hibernate Query Language API, with examples
  • Develop Java Persistence API applications, using Hibernate as the provider
  • Work hands-on with code snippets to understand the technology

Table of contents

  1. Foreword
  2. Preface
    1. Who Should Read This Book
    2. Why I Wrote This Book
    3. How This Book Is Organized
    4. Conventions Used in This Book
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
    9. A Note from the Author
  3. Dedication
  4. 1. Basics
    1. Birth of Hibernate
    2. Problem Domain
      1. MovieManager Application
        1. Using JDBC
      2. Improvising the Movie Application
    3. Using Hibernate
    4. Configure the Database Connection
    5. Create Mapping Definitions
    6. Persist the Objects
      1. Creating the Persist Method
      2. Testing the Persisted Data
    7. Setting Up Hibernate
    8. Summary
  5. 2. Fundamentals
    1. Object-Relational Mismatch
      1. Inheritance Mismatch
      2. Identity Mismatch
      3. Relations and Associations Mismatch
    2. Hibernate’s Main Parts
    3. Persistent Classes
    4. Example: Trading Application
    5. Using Annotations
    6. Configuration
      1. Using a Properties File
      2. Using the XML File
      3. Configuration Properties
      4. Programmatic Configuration
    7. Mapping
    8. XML Mapping Files
    9. Identifier Generation Strategies
    10. Session APIs
    11. Transactions
    12. Summary
  6. 3. Annotations
    1. Working Through an Example
    2. Digging into Details
    3. ID Generation Strategies
    4. Composite Identifiers
      1. Using Primary Key Class and @Id
      2. Using Primary Key Class and @EmbeddedId
      3. Using @IdClass
    5. Summary
  7. 4. Persisting Collections
    1. Designing to Interfaces
    2. Persisting Lists
      1. List Example: Car Showroom
      2. Test Client for List Persistence
    3. Persisting Sets
    4. Persisting Maps
    5. Persisting Arrays
    6. Persisting Bags and IdBags
    7. Persisting Collections Using Annotations
      1. Using a Foreign Key
      2. Using a Join Table
    8. Summary
  8. 5. Associations
    1. Associations
      1. Multiplicity
      2. Directionality
    2. One-to-One Association
      1. Using a Primary Key
      2. Testing the Association
      3. Using a Foreign Key
      4. Annotations
    3. One-to-Many (or Many-to-One) Association
    4. Bidirectional One-to-Many Association
    5. Many-to-Many Association
    6. Summary
  9. 6. Advanced Concepts
    1. Hibernate Types
      1. Entity and Value Types
      2. Custom Types
    2. Components
    3. Caching
      1. First-Level Caching
      2. Second-Level Caching
      3. Caching Queries
    4. Inheritance Strategies
      1. Table-per-Class Strategy
        1. Table-per-class strategy using XML mapping
        2. Table-per-class strategy using annotations
      2. Table-per-Subclass Strategy
        1. Table-per-subclass strategy using XML mapping
        2. Table-per-subclass using annotations
      3. Table-per-Concrete-Class Strategy
      4. Table-per-Concrete-Class Strategy Using XML mapping
        1. Table-per-concrete-class strategy using annotations
    5. Filters
      1. Creating Filter Definitions
      2. Enabling Filters
    6. Relationship Owner (aka Inverse Attribute)
    7. Cascading Entities
    8. Summary
  10. 7. Hibernate Query Language
    1. Working with the Query Class
      1. Fetching All Rows
      2. Pagination
      3. Retrieving a Unique Record
      4. Named Parameters
      5. Using the IN option
      6. Positional Parameters
      7. Aliases
      8. Iterators
      9. Selects
      10. Aggregate Functions
      11. Updates and Deletes
      12. Criterias
      13. Named Queries
    2. Native SQL
    3. Summary
  11. 8. Java Persistence API
    1. Hibernate and JPA
      1. Persistence Context
      2. EntityManagerFactory
      3. EntityManager
    2. Persisting Objects
    3. Saving and Querying Entities
    4. Summary
  12. Index
  13. Colophon
  14. Copyright

Product information

  • Title: Just Hibernate
  • Author(s): Madhusudhan Konda
  • Release date: June 2014
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449334338