Java Persistence API


This course is a thorough introduction to version 2.2 of the Java Persistence API and explore everything that it has to offer developers. One of its strengths is that it can be slotted into whichever layer, tier, or framework an application needs it to be in. Whether you are building client-server applications to collect form data in a Swing application or building a web site using the latest application framework, JPA can help you to provide persistence more effectively.

Category: Tags: ,
Product Description

This Java Persistence API training course explores using the Java Persistence API within the context of a

  • Java Standard Edition application
  • Web-based Java Enterprise Edition application (and using Java Persistence API with EJB’s).

Prerequisites / Further Training

Java Servlets Beginner Java Servlets Advanced
Java Enterprise Edition Enterprise Java Beans
Java Persistence API Java Web Services
Java Server Faces (under construction) Spring Framework

You do not need to be familiar with Java EE

Course Material

  • Included in the course price.
  • We use Glassfish Application Server 4.0 + for our course exercises

After this course you should be able to:

  • Understand key concepts found in the Java Persistence API.
  • Update multiple database tables based on relationships.
  • Perform CRUD operations with JPA in Java SE and EE environments.
  • Perform data validation using Bean Validation.
  • Optimize JPA for performance. Apply transactions and locking.
  • Map relational database tables to Java using ORM techniques and JPA.
  • Create robust entity models.
  • Create static and dynamic queries using JPQL.
  • Create type-safe queries with the Java Persistence API Criteria API.
  • Prepare for the Java EE 6 Java Persistence API Developer Certified Expert 1Z0-898 exam (not included)


Day 1


  • Relational Databases
    Object-Relational Mapping
    The Impedance Mismatch
    Java Support for Persistence
    Proprietary Solutions
    Enterprise JavaBeans
    Java Data Objects
    Why Another Standard?
    The Java Persistence API
    History of the Specification

Getting Started

  • Entity Overview
    Entity Metadata
    Configuration by Exception
    Creating an Entity
    Entity Manager
    Obtaining an Entity Manager
    Persisting an Entity
    Finding an Entity
    Removing an Entity
    Updating an Entity
    Putting It All Together
    Packaging It Up
    Persistence Unit
    Persistence Archive

Enterprise Applications

  • Application Component Models
    Session Beans
    Stateless Session Beans
    Stateful Session Beans
    Singleton Session Beans
    Dependency Management and CDI
    Dependency Lookup
    Dependency Injection
    Declaring Dependencies
  • CDI and Contextual Injection
    CDI Beans
    Injection and Resolution
    Scopes and Contexts
    Qualified Injection
    Producer Methods and Fields
    Using Producer Methods with JPA Resources
    Transaction Management
    Transaction Review
    Enterprise Transactions in Java
    Putting It All Together
    Defining the Component
    Defining the User Interface
    Packaging It Up

Day 2

Object-Relational Mapping

  • Persistence Annotations
    Accessing Entity State
    Field Access
    Property Access
    Mixed Access
    Mapping to a Table
    Mapping Simple Types
    Column Mappings
    Lazy Fetching
    Large Objects
    Enumerated Types
    Temporal Types
    Transient State
    Mapping the Primary Key
    Overriding the Primary Key Column
    Primary Key Types
    Identifier Generation
    Relationship Concept
    Mappings Overview
    Single-Valued Associations
    Collection-Valued Associations
    Lazy Relationships
    Embedded Objects

Collection Mapping

  • Relationships and Element Collections
    Using Different Collection Types
    Sets or Collections
    Null Values
    Best Practices

Entity Manager

  • Persistence Contexts
    Entity Managers
    Container-Managed Entity Managers
    Application-Managed Entity Managers
    Transaction Management
    JTA Transaction Management
    Resource-Local Transactions
    Transaction Rollback and Entity State
    Choosing an Entity Manager
    Entity Manager Operations
    Persisting an Entity
    Finding an Entity
    Removing an Entity
    Cascading Operations
    Clearing the Persistence Context
    Synchronization with the Database
    Detachment and Merging
    Merging Detached Entities
    Working with Detached Entities

Day 3

Using Queries

  • Java Persistence Query Language
    Getting Started
    Filtering Results
    Projecting Results
    Joins Between Entities
    Aggregate Queries
    Query Parameters
    Defining Queries
    Dynamic Query Definition
    Named Query Definition
    Dynamic Named Queries
    Parameter Types
    Executing Queries
    Working with Query Results
    Query Paging
    Queries and Uncommitted Changes
    Query Timeouts
    Bulk Update and Delete
    Using Bulk Update and Delete
    Bulk Delete and Relationships
    Query Hints
    Query Best Practices
    Named Queries
    Report Queries
    Vendor Hints
    Stateless Beans
    Bulk Update and Delete
    Provider Differences

Query Language

  • Introducing JP QL
    Example Data Model
    Example Application
    Select Queries
    SELECT Clause
    FROM Clause
    WHERE Clause
    Inheritance and Polymorphism
    Scalar Expressions
    ORDER BY Clause
    Aggregate Queries
    Aggregate Functions
    GROUP BY Clause
    HAVING Clause
    Update Queries
    Delete Queries

Criteria API

  • Overview
    The Criteria API
    Parameterized Types
    Dynamic Queries
    Building Criteria API Queries
    Creating a Query Definition
    Basic Structure
    Criteria Objects and Mutability
    Query Roots and Path Expressions
    The SELECT Clause
    The FROM Clause
    The WHERE Clause
    Building Expressions
    The ORDER BY Clause
    The GROUP BY and HAVING Clauses
    Bulk Update and Delete
    Strongly Typed Query Definitions
    The Metamodel API
    Strongly Typed API Overview
    The Canonical Metamodel
    Choosing the Right Type of Query

Day 4

Advanced Object-Relational Mapping

  • Table and Column Names
    Converting Entity State
    Creating a Converter
    Declarative Attribute Conversion
    Automatic Conversion
    Converters and Queries
    Complex Embedded Objects
    Advanced Embedded Mappings
    Overriding Embedded Relationships
    Compound Primary Keys
    Id Class
    Embedded Id Class
    Derived Identifiers
    Basic Rules for Derived Identifiers
    Shared Primary Key
    Multiple Mapped Attributes
    Using EmbeddedId
    Advanced Mapping Elements
    Read-Only Mappings
    Advanced Relationships
    Using Join Tables
    Avoiding Join Tables
    Compound Join Columns
    Orphan Removal
    Mapping Relationship State
    Multiple Tables
    Class Hierarchies
    Inheritance Models
    Mixed Inheritance

Advanced Queries

  • SQL Queries
    Native Queries vs. JDBC
    Defining and Executing SQL Queries
    SQL Result Set Mapping
    Parameter Binding
    Stored Procedures
    Entity Graphs
    Entity Graph Annotations
    Entity Graph API
    Managing Entity Graphs
    Using Entity Graphs

Other Advanced Topics

  • Lifecycle Callbacks
    Lifecycle Events
    Callback Methods
    Entity Listeners
    Inheritance and Lifecycle Events
    Using Constraints
    Invoking Validation
    Validation Groups
    Creating New Constraints
    Validation in JPA
    Enabling Validation
    Setting Lifecycle Validation Groups
    Entity Operations
    Entity Access
    Refreshing Entity State
    Optimistic Locking
    Pessimistic Locking
    Sorting Through the Layers
    Shared Cache
    Utility Classes

Day 5

XML Mapping Files

  • The Metadata Puzzle
    The Mapping File
    Disabling Annotations
    Persistence Unit Defaults
    Mapping File Defaults
    Queries and Generators
    Managed Classes and Mappings

 Packaging and Deployment

  • Configuring Persistence Units
    Persistence Unit Name
    Transaction Type
    Persistence Provider
    Data Source
    Mapping Files
    Managed Classes
    Shared Cache Mode
    Validation Mode
    Adding Properties
    Building and Deploying
    Deployment Classpath
    Packaging Options
    Persistence Unit Scope
    Outside the Server
    Configuring the Persistence Unit
    Specifying Properties at Runtime
    System Classpath
    Schema Generation
    The Generation Process
    Deployment Properties
    Runtime Properties
    Mapping Annotations Used by Schema Generation
    Unique Constraints
    Null Constraints
    Foreign Key Constraints
    String-Based Columns
    Floating Point Columns
    Defining the Column


  • Testing Enterprise Applications
    Testing Outside the Server
    Unit Testing
    Testing Entities
    Testing Entities in Components
    The Entity Manager in Unit Tests


Duration and pricing

In Price Group A


Read about our Certificates


You can download the course registration form on our home page or by clicking here


You may download a pdf copy of this page by clicking on the pdf icon at the top of the page.


Please email us Schedule On the calendar below. If your browser doesn’t display the calendar below, please click on this link or try using Google Chrome, alternatively please enquire via our Contact Us page.

Print Friendly, PDF & Email