Java Persistence API 2 Development

The Java Persistence API (JPA) is a standard object-relational mapping (ORM) technology for Java Enterprise Edition applications. This course takes a detailed look at JPA 2, describing how to map complex relational structures and how to use the Java Persistence Query Language (JPQL) effectively.


3 days



  • At least 6 months Java programming experience
  • Familiarity with relational databases and SQL

What you'll learn

  • Understanding persistence in Java EE
  • Mapping classes to tables
  • Using JPA to query entities
  • Using advanced query techniques
  • Managing entity lifetimes
  • Mapping associations and collections
  • Mapping inheritance hierarchies
  • Using the Criteria API

Course details

Persistence in Java EE

  • Entity beans
  • EntityManager and Persistence Units
  • Mapping entity classes to relational databases
  • Providing metadata via annotations and XML
  • Using the Java Persistence API
  • Summary of JPA 2.0 features

JPA Queries

  • Overview of Java Persistence Query Language (JPQL)
  • Lazy and eager Loading
  • Queries
  • Parameters
  • Paging and scrolling
  • Projections
  • Aggregates

Going Further with JPA Queries

  • Queries across relationships (inner joins, outer joins, fetch joins)
  • Batch operations
  • Bulk updates
  • Named queries
  • Native queries
  • Primary key generation

Using the Criteria API

  • Overview of the Criteria API
  • Building Criteria API queries
  • Strongly typed query definitions

Working with Persistent Objects

  • Entity lifecycle
  • Entity identity
  • Transient, persistent, and detached states
  • Persistent object updates

Mapping Collections and Associations

  • Fetching strategies
  • Many-to-one
  • Bidirectional many-to-one
  • One-to-one
  • Bidirectional one-to-one
  • Many-to-many
  • Bidirectional many-to-many
  • Components
  • Embedded objects
  • Cascading

Mapping Inheritance

  • Overview
  • Inheritance mapping strategies
  • Table per concrete class
  • Table per subclass
  • Table per hierarchy
  • Unions
  • Polymorphism

Transaction Management

  • Transaction configuration
  • Transaction API
  • Transaction propagation

Locking and Versioning

  • Optimistic locking and versioning
  • Pessimistic locking