Complete Hibernate and Java Persistence API

Course Description

This course teaches students the Java specification for persisting objects to the database. It does so through Hibernate - the most popular JPA implementation and object-relational mapping framework for Java environments. Object relational mapping in large enterprise applications is difficult. The task is so difficult that the problem of storing and retrieving objects to a relational database has its own name - impedance mismatch.
In this class, students learn object-relational mapping concepts and the various issues and options available in Java to address object persistence. With these fundamentals, the course then explores the basics of JPA/Hibernate object persistence and configuration. It also digs into the details of mapping, queries, transactions, and concurrency.
Not just a class that focuses on theory, this course is loaded with practical labs and deals with maintenance and performance issues. After taking this class, developers will be able to build faster, more flexible and easier to maintain application persistence layers and overcome impedance mismatch with JPA implementations like the Hibernate framework.
5 days
Contact us for pricing
 

Prerequisites

Students should have a good understanding of the Java programming language. A basic understanding of relational databases and SQL is very helpful.

Audience

This class is designed for Java programmers with a need to understand the Java persistence provided by Hibernate or JPA framework and API.

Learning Objectives

- Understand the challenges of mapping objects to relational databases
- Learn the architecture of Hibernate and JPA
- Know how to setup and configure Hibernate and/or JPA for a Java project
- Learn to map Java classes and object associations to relational database tables with JPA and Hibernate annotations
- Learn to map Java classes and object associations to relational database tables with Hibernate or JPA XML mapping files
- Study strategies for mapping Java inheritance trees to relational database tables
- Learn the Hibernate Query Language, Java Persistence Query Language and Criteria for retrieving Java objects
- Explore how to manage database transactions
- Look at optimistic and pessimistic concurrency options provided by Hibernate and JPA

Object Persistence

Persistence
Object Persistence
Object/Relational Paradigms
Impedance Mismatch
Object Relational Mapping (ORM)
Hibernate
Why an ORM framework? Why Hibernate?
Java Persistence API (JPA)
Hibernate Projects
Java ORM/Persistent Frameworks

Hibernate

A Quick Hibernate Example
Hibernate Architecture and API
Hibernate Installation/Setup
Configuration
Configuration Properties
Mapping Files

JPA

A Quick JPA Example
JPA Architecture and API
Hibernate Installation/Setup with JPA
Persistence Configuration
Mapped Entities and Mapping Files

Entity Mapping by Annotation

Persistent Classes
POJOs
JavaBeans
Annotation Metadata
Annotation Configuration
Basic Entity Mapping via Annotations
Basic Property Mapping via Annotation
ID Mapping via Annotation
Composite Keys (and Natural Keys)
Access Type
Hibernate Mapping Annotations

Entity Mapping by XML

XML Metadata
XML vs. Annotatin - Pros/Cons
Hibernate XML Metadata Basics
JPA XML Metadata Basics
Basic Entity Mapping via XML
Basic Property Mapping via XML
Hibernate Types
ID Mapping via XML
Identifier Exposure
Access Type

Persistence Context

Entity Lifecycle
New or Transient State
Managed or Persistent State
Entity Updates and Automatic Dirty Checking
Flushing
Detached State
Detached State - Why?
Remove/Delete
Object Identifiers Revisited
Detached & Merge Revisited
Refresh

Embeddables and Components

Domain Model
Entities and Values
Embeddables and Components
Embeddable by Annotation
JPA Embeddable by XML
Hibernate Component by XML
Component Bidirectional Association
Issues and Warnings for Embeddables/Components
Embeddable Composite Id
Purpose of Embeddables/Components

Entity Associations

Many-to-one
Many-to-One by Annotation
Many-to-One by XML mapping
Bidirectional Many-to-One
Bidirectional Many-to-One by Annotation
Bidirectional Many-to-One by XML
Other Collection Types
Many-to-One List
Many-to-One Bag
Many-to-One Map

More Associations

One-to-one
One-to-one by Annotation
One-to-one by XML
Bidirectional One-to-One
Bidirectional One-to-One by Annotation
Bidirectional One-to-One by XML
Many-to-many
Many-to-many by Annotation
Many-to-many by XML
Bidirectional Many-to-Many
Bidirectional Many-to-Many with Annotations
Bidirectional Many-to-Many with XML

Value Type Collections

Collections of Value Types
Collections of Embeddables/Components

Inheritance

Inheritance Mapping Strategies
Table per Hierarchy
Table per Subclass
Table per Concrete Class
Table per Concrete Class with Mapped Superclass
Inheritance Mapping Pros/Cons
Polymorphism
Table per Concrete Class with Unions
Choosing an Inheritance Strategy

Cascading/Loading

Cascading/Transitive Persistence
Lazy Loading
Proxies
Eager Loading
What's a Proxy?
Detached Objects and Proxies
Polymorphic Associations Revisited

Queries

Persistent Object Fetching Options
Hibernate Query
HQL
HQL Parameters
JPA Query and JPQL
Named Queries
Native SQL

Criteria

Criteria
Criteria Select
Criteria Inner/Outer Joins
Criteria Parameters
Criteria Where
Criteria Order
Metamodel
Pagination and Query Hints
Hibernate Scrolling
Query Option Pros/Cons

Transactions and Concurrency

The Java Transaction
Hibernate Transaction Configuration
Hibernate Transaction API
JPA Transaction Configuration
JPA Transaction API
Optimistic Locking
Versioning
Hibernate Optimistic Locking without Versioning
Pessimistic Locking API

HibernateJavaJava Persistence APIJPA