Fast Track to the Java Persistence API Version 2

This 3 day Java Persistence API training class covers everything you need to know to begin working with the Java Persistence API in a very short time. It covers all the important concepts necessary to access and update data stored in relational databases. It includes an extensive series of labs to exercise all major capabilities.

Goals

  • Understand the JPA architecture
  • Learn to create JPA based applications
  • Understand and use JPA to map persistent objects to the database
  • Learn to create JPA persistence units, and understand JPA persistence contexts and the Entity Lifecycle
  • Learn to use the JPA EntityManager
  • Learn to work with queries and JPQL (Java Persistence Query Language), as well as the Criteria API (JPA 2)
  • Understand and work with collections & associations
  • Learn to use versioning support for optimistic locking
  • Learn to map inheritance hierarchies using JPA
  • Learn how to performance tune your JPA applications
  • Understand JPA transaction support
  • Understand the relationship between JPA / EJB3
  • Use JPA entities from session beans (Optional)
  • Be familiar with Spring support for JPA (Optional)

Outline

  1. Introduction to Java Persistence API (JPA)
    1. Overview
      1. Persistence Layers, Object-Relational Mapping (ORM), JDBC
      2. JPA Overview
    2. Mapping with JPA
      1. Entities and @Entity, ids and @Id,
      2. Generated Id Values
      3. Basic Mapping Types
    3. Persistence Unit and EntityManager
      1. Persisting to the DB, the EntityManager API
      2. Persistence Units, Config, Persistence Context
      3. Retrieving Persistent Entities with find()
    4. More About Mappings
      1. Default Mappings, @Basic, @Column
      2. Field vs. Property Access
      3. Temporal (Date/Time) Mappings
    5. Logging Options (Provider based)
  2. Updates and Queries
    1. Inserting and Updating – Persisting new Entities, Updating an Instance, Removing an Instance
    2. Querying and JPQL
      1. Entity Based Queries, SELECT ,WHERE
      2. Query Interface, Executing Queries, Generic Queries (JPA 2)
      3. JPQL Operators, Expressions, and Parameters
      4. Named Queries
    3. Additional Query Capabilities
      1. Projection query, Ordering, Aggregate Query, Build Update and Delete
    4. Embedded Objects
      1. @Embeddable, @Embedded
      2. Defining and using Embedded Objects
    5. Compound Primary Keys – @EmbeddedID, @IDClass, Defining Compound Keys
  3. The Persistence Lifecycle
    1. Transaction Overview and Transactions in JPA
      1. Transaction Overview
      2. EntityTransaction API (including JTA and resource-local EntityManager)
    2. The Persistence Lifecycle
      1. JPA Entity States (New, Managed, Detached, Removed), and Entity State Diagram
      2. Persistence Context – Lifespan, Propagation
      3. Synchronization to the DB
    3. Versioning and Optimistic Locking
      1. Overview, Detached Instances
      2. Versioning, @Version, Optimistic Locking
    4. Lifecycle Callbacks
      1. @PrePersist, @PostPersist, etc.
      2. Entity Listeners, @EntityListeners
  4. Entity Relationships
    1. Relationships Overview: Object Relationships, Participants, Roles, Directionality, Cardinality
    2. Relationship Mapping
      1. Mapping Overview (1-1, 1-N, N-1, N-N)
      2. Unidirectional and Bidirectional
      3. @ManyToOne, @OneToMany, Table Structures
      4. Relationship Inverse – Owning Side
      5. Collection Types (List, Set, etc)
      6. Cascading Over Relationships (including orphanRemoval – JPA 2)
      7. @ManyToMany, @OneToOne
      8. Lazy and Eager Loading
      9. Queries Across Relationships (Inner Joins, Outer Joins, Fetch Joins)
    3. Entity Inheritance Mapping
      1. Overview
      2. Single Table Mapping
      3. Joined (Table per Subclass) Mapping
      4. Table per Concrete Class Mapping
      5. Pros and Cons
    4. Element Collections (JPA 2)
      1. Overview, Collections of Value Objects, @ElementCollection, @CollectionTable
      2. Using Element Collections
      3. Collections of Embeddables
  5. The Crietria API (JPA 2)
    1. Overview of the Criteria API
    2. Path Expressions, Building Queries (CriteriaBuilder, CriteriaQuery, Subquery, Predicate, Expression, Order, Selection, Join)
    3. Executing Queries and Accessing Results
  6. Additional JPA Capabilities
    1. XML Mapping Files
    2. Bean Validation (JPA 2)
    3. Best Practices
      1. Primary Keys, Named Queries, Lazy/Eager Loading, Transactional Semantics, Encapsulation, Report Queries
  7. Integration
    1. Data Access Objects (DAO) and Java SE Integration (Optional)
      1. DAO Overview
      2. JpaUtil Class for EntityManager management in Java SE
      3. Lifecycle Considerations
    2. Integration with EJB (Optional)
      1. Using JPA with Session Beans
      2. Container Managed (Injected) Entity Manger
      3. JTA Transactions and Lifecycle Considerations
      4. Extended Persistence Contexts
    3. Using JPA with Java Web Apps
      1. Using EntityManager in Web apps – request scoping
      2. Lazy Loading – Open EntityManager in View Pattern
    4. Integration with Spring (Optional)
      1. Injection of EntityManger, EntityManagerFactory
      2. LocalEntityManagerFactoryBean
      3. JPA/Spring Based DAO

To Hire an AMS Java Web Applications Subject Matter Expert and Instructor who also teaches this class, call us today at 800-798-3901!

Leave a Reply