Java Persistent API (JPA)

Part of our "Java & Spring" courses

3 days

Course Overview

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).

Course Prerequisites

Students should be experience with Java Platform and language, Ideally attendees should have 8 to 10 months experience with Java development



  • Architecture of JPA
  • When to use JPA (benefits), and when not to use JPA (disadvantages)
  • Problems solved 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


  • 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


  • 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 the impact on instanceof and type-casting



  • 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


  • 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 the 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 a real-life case driven by integration tests using Arquillian.

Private Events

Is your team in need of a a Java Persistent API (JPA) course?

Send us a message, and we'll get in touch, without any obligation.


Request a free quote

This Java Persistent API (JPA) course looks very interesting, I do however have a question