TT3200: Mastering Hibernate for Persistence in Java

Contact PI


  • Virtual Classroom

  • Onsite
Duration: 4 Days

Hibernate is a powerful enabler that addresses object/relational persistence in the Java world. Hibernate offers all the advantages of developing in Java plus a comprehensive suite of capabilities for mapping object-oriented features to the relational model. In this course, you will learn how to design and build your own Hibernate-enabled applications. You'll learn the details of Hibernate capabilities and how to leverage their strengths, with a special focus on using Hibernate with other technologies and frameworks.

You will explore data/class mapping, persisted object lifecycle and management, and how to query for persistent objects. At the same time, you'll cover the big picture of Hibernate and how to design applications to use Hibernate in a robust, efficient, secure, and maintainable fashion. Multiple detailed lab exercises are laced throughout the course, designed to reinforce fundamental skills and concepts learned in the lessons.

What You Will Learn

 

  • Hibernate addresses issues associated with object persistence in a relational model
  • Relationships between SQL, Java, JDBC, Spring, Java Persistence API, EJB 3.0, and Hibernate
  • Challenges to adopting Hibernate in the enterprise
  • Write applications that take advantage of the Hibernate Persistence Manager
  • Map Java classes to relational tables
  • Capture both relational and inheritance associations in metadata using either XML or the Java 5 Annotations mechanism
  • Create and use mappings between Java classes and relational databases
  • Identity and keys in Hibernate
  • Persistent object lifecycle and how that relates to transactions and concurrency
  • Hibernate's data filtering and interception

Audience

 

Developers at an intermediate level and beyond with Java/Hibernate, who need to understand how and when to use Hibernate in Java or JavaEE /J2EE applications

Prerequistes

 

Basic Java development experience

Course Outline

 

1. Hibernate

  • Object-Relational Mapping (ORM) Issues
  • Hibernate Architecture
  • Persistence, Identity, and Equality in Hibernate
  • Domain Models and Metadata Options
  • Options for Representing Persistence

2. Getting Started with Hibernate

  • Basic Mapping
  • Basic Configuration
  • Mapping a Plain Old Java Object (POJO) to a Database
  • Syntax of Mapping File
  • Basics of Hibernate Session
  • Working with Persisted Objects

3. Basic ORM in Hibernate

  • Configuring Persistence
  • Object Identity in Hibernate
  • Generating Unique Keys
  • Mapping Classes to Multiple Tables

4. Value-Type Collections and Components

  • Element Types
  • Mapping Compositions
  • Mapping Java Collections
  • Bags and Dynamic Components

5. Entity Associations (Relations)

  • Types of Associations
  • Uni- and Bi-Directional Associations
  • Using Join Tables
  • Many-to-Many Associations
  • Cascading Over Associations

6. Mapping Inheritance

  • Strategies for Inheritance ORM
  • Single, Class, and Concrete Table Patterns
  • Discriminators

7. Hibernate Annotations

  • Annotation-Capable Sessions
  • Annotations and Persistence
  • Annotations, Mapping, and Relationships

8. Persistent Objects

  • Reading, Updating, and Deleting Objects
  • Transient, Persistent, and Detached
  • Transitioning Between States
  • Options for Retrieving Objects
  • Attached and Detached States
  • Update, Merge, and Cascade

9. Transactions

  • Transaction Control and Isolation Levels
  • Options for Demarcating Transactions
  • Using a Contextual Session
  • Correctly Handling Exceptions
  • Optimistic and Pessimistic Locking in Hibernate
  • Lock Scopes and Cascading

10. Querying for Objects

  • Hibernate Query API
  • Hibernate Query Language (HQL)
  • HQL Syntax and Usage
  • Criteria

11. Hibernate and Java Persistence API (JPA)

  • Entities and Metadata
  • Entity Manager
  • Finding Entities
  • Implementation Options
  • Hibernate as a JPA Option
  • Mechanics of using Hibernate for JPA

Course Labs

 

This course is approximately 50% dynamic lab exercises and 50% lecture, designed to train you in essential Spring and Hibernate development skills, coupling the most current programming techniques with the soundest industry practices.