Java Persistent API 2.x (JPA)

Duration: 3 days

This very comprehensive JPA course teaches provides you with the necessary skills, knowledge and comprehension to build application using JPA (correctly and with performance in mind).

Please find the course objectives below:

Introduction

  • Architecture of JPA
  • When to use JPA (benefits), and when not to use JPA (disadvantages)
  • Problems solves by an ORM

Getting Started

  • JPA Configuration (defining a persistence unit)
  • Writing Entities
  • Provide mapping meta-data using XML
  • Provide mapping meta-data using annotations
  • Introduction to the EntityManagerFactory and EntityManager
  • Use the EntityManager API
  • Injecting EntityManagerFactory and EntityManager instances
  • Introduction to transactions

Core ORM

  • list different types of objects (Entities, values, embeddables, collections)
  • Mapping entities to tables
  • Use various primary keys strategies
  • Mapping columns
  • Model composites/aggregates using Embeddables
  • Mapping collections and maps of values and embeddables

Associations

  • Recap OO semantics of associations
  • Map one-to-one using shared pirmary key
  • Mapping one-to-one using a foreign key
  • Map one-to-many/many-to-one using foreign keys and mapping tables
  • Map many-to-one and many-to-many using mapping tables
  • Map bidirectional and unidirectional associations
  • Appreciate the passive (aka inverse) end of the associations
  • Cascade options
  • Mapping Qualified Associations using java.util.Map
  • Manage lazy loading
  • Discuss performance implications

Inheritance

  • Discuss various options for mapping inheritance
  • Map using Single Table per Class Hierarchy
  • Map using Joined Subclass
  • Map using Table per Concrete class
  • Understand discriminators (columns/values)
  • Discuss performance implications per inheritance mapping strategy
  • Understand impact on instanceof and type-casting

Queries

JPQL

  • Explain the JPQL syntax in depth
  • Using named queries
  • Ordering results
  • Using where clauses
  • Using parameters
  • Aggregate values using group by
  • Understand scalar expressions
  • Using the case statements
  • Joining entities (theta, inner, left outer)
  • Using fetch joins
  • Joining collection members
  • Perform bulk updates using JPQL

Criteria API

  • Building type-safe queries
  • Understand the CriteriaBuilder API
  • Generate and use a static metamodel
  • Selecting from multiple roots
  • Defining where clauses
  • Working with parameters
  • Joining data
  • Using fetch joins with the criteria API

Native queries

  • Understand the default mapping of native SQL queries
  • Use custom mapping

Life-cycle

  • Understand different entity states: transient, persistent and detached
  • Understand how to transition from one state to another
  • More on transactions
  • Discuss concurrency options
  • Understand detached entities and application design
  • Apply optimistic locking using versioning
  • Use pessimistic locking with database locks
  • Discuss benefits of Caching
  • Setting up a shared cache
  • Setting up a clustered cache
  • Configuring the cache (size, time to live, etc)
  • bypassing the cache in code
  • Discuss Hibernate fetch strategies (optional)

During the course you will be working on real-life case driven by integration tests using Arquillian.

For an onsite course please contact us