Skip to main content

Instructor-led training

JPA with Hibernate Training in Juneau, Alaska

This course offers a comprehensive and detail-oriented treatment of Hibernate 4.0 and the Java Persistence API (JPA) 2.0 for developers interested in implementing persistence tiers for enterprise applications.

What you'll learn

This course offers a comprehensive and detail-oriented treatment of Hibernate 4.0 and the Java Persistence API (JPA) 2.0 for developers interested in implementing persistence tiers for enterprise applications. We cover JPA basics including simple object/relational concepts and annotations, persistence contexts and entity managers, and configuration via persistence.xml. We get a good grounding in the Java Persistence Query Language (JPQL) and take advantage of a prepared JPQL query console to explore the two schemas on which the course's case studies are based. The course then moves into advanced topics including JPA-2.0 mapping options, the Criteria API, lifecycle hooks, JSR-303 validation, locking, and caching. Students will complete the course with a firm understanding of JPA architecture and plenty of hands-on exercise in entity mapping, persistence operations, and JPQL. Course software includes two schemas: a fairly simple human-resources model (6 tables, 253 rows) for early chapters and a more sophisticated pharmacy schema (14 tables, 4255 rows) for the latter half of the course. The course supports either the Derby or Oracle RDBMS. Derby is bundled with the course software and is pre-configured; a script is included to change over to Oracle configurations for all exercises and schema-creation scripts are available for both.

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Juneau, Alaska or live online. Dates, delivery format, and course content are arranged around your team's requirements.

This course is not currently scheduled as a public class for individual enrollment.

Request Group Training

Prerequisites

A strong Java programming background is essential for this course. Knowledge of relational database concepts and SQL is recommended. Prior experience with JDBC will be a plus but is not required.

Course Outline

Chapter 1. Introduction to JPA

  • Object/Relational Mapping
  • Mismatches Between Relational and Object Models
  • The Java Persistence API
  • Hibernate
  • History
  • Architecture
  • Entity Metadata
  • The Entity Manager

Chapter 2. Object/Relational Mapping

  • Annotations
  • JavaBean Standards
  • Property, Field, and Mixed Access
  • Table and Column Mapping
  • Primary Keys and Generation
  • Type Mappings
  • Temporal and Enumerated Types
  • Embedded Types
  • Entity Relationships
  • @ManyToOne Relationships
  • @OneToOne Relationships
  • @OneToMany Relationships
  • @ManyToMany Relationships
  • Eager and Lazy Loading

Chapter 3. Entity Managers

  • Putting Entities to Work
  • persistence.xml
  • Entity State and Transitions
  • Managing Transactions
  • Persistence Operations
  • Creating Queries
  • Named Queries
  • Query Parameters
  • Native Queries

Chapter 4. JPQL

  • The Java Persistence Query Language
  • HQL and JPQL
  • Query Structure
  • Path Expressions
  • Filtering
  • Scalar Functions
  • Operators and Precedence
  • between, like, in
  • is null, is empty
  • Ordering
  • Aliases
  • Grouping
  • Aggregate Functions
  • Joins
  • Constructors

Chapter 5. Advanced Mappings

  • Inheritance Strategies
  • Single-Table Strategy
  • Joined-Table Strategy
  • Table-Per-Concrete-Class Strategy
  • Querying Over Inheritance Relationships
  • Type Identification with .class
  • Secondary Tables
  • Composite Primary Keys
  • @IdClass and @EmbeddedId
  • Derived Identifiers
  • @ElementCollection
  • Default Values
  • @Version Fields
  • Cascading and Orphan Removal
  • Detachment and Merging
  • Hibernate Extensions
  • The @Type Annotation

Chapter 6. The Criteria API

  • History of the Criteria API
  • Criteria Query Structure
  • The MetaModel API and Query Type Safety
  • The Hibernate Metamodel Generator
  • Tuples
  • Joins
  • Predicates
  • Building Expressions
  • Ordering
  • Grouping
  • Encapsulating Persistence Logic
  • Façades
  • Range Queries

Chapter 7. Lifecycle and Validation

  • Lifecycle Events
  • Method Annotations
  • Entity Listeners
  • JSR-303 Validation
  • The Hibernate Validator
  • Constraint Annotations
  • Validation Modes
  • Validation Groups

Chapter 8. Locking and Caching

  • Concurrency
  • Optimistic Locking
  • Optimistic Read Locking
  • Optimistic Write Locking
  • Pessimistic Locking
  • Caching
  • Persistence Context as Transactional Cache
  • Shared (2nd-level) Cache
  • Locking and Caching "Do's and Don'ts"

Where JPA and Hibernate get difficult

The annotations are easy to learn. The hard part is predicting what the persistence provider does with them. The syllabus starts with the mismatches between relational and object models, and most later topics deal with one of them.

  • Mapping. Chapter 2 covers table and column mapping, primary key generation, embedded types, and the four relationship types. Eager versus lazy loading is a decision made here, and it later decides how many queries run. Lazy loading and N+1 queries are among the most common sources of ORM performance bugs.
  • Entity state. Chapter 3 covers entity state transitions, transactions, and the persistence context. Chapter 5 adds detachment and merging, cascading, and orphan removal. A common misconception is that merge simply means save. In fact it copies state onto a managed instance, and that distinction matters when entities pass between tiers.
  • Two query languages. JPQL (Chapter 4) is string-based and resembles SQL, but it queries entities and path expressions, not tables. The Criteria API (Chapter 6) builds queries programmatically, and the metamodel adds type safety. It is more verbose, so the course also covers encapsulating persistence logic in facades.
  • Advanced mapping. Three inheritance strategies, composite keys (@IdClass and @EmbeddedId), derived identifiers, secondary tables, and @ElementCollection each change the schema and the queries you can write.
  • Concurrency. Chapter 8 covers optimistic and pessimistic locking, the persistence context as a transactional cache, and the shared second-level cache. Caching is often assumed to be a free speedup, but it can return stale data if you do not understand it.

The chapters build in order: mapping, then entity manager operations, then queries, then advanced mappings, then Criteria, lifecycle hooks and validation, and finally locking and caching.

Who this course suits and what to take around it

The course is for Java developers who build or maintain persistence tiers for enterprise applications. A strong Java background is essential. Knowledge of relational concepts and SQL is recommended, because you will compare generated and hand-written queries. JDBC experience helps but is not required.

Teams whose persistence code runs inside an application server may want Fast Track to EJB 3.2 (JEE 7 level) and JPA2. It pairs JPA with EJB, which is where container-managed transactions and entity manager injection usually come from. Teams that expose persisted data over HTTP can follow this course with Developing RESTful Services Using Java, which covers the service layer above the persistence tier.

Organizations on a specific Hibernate or JPA version can ask about private training tailored to the versions they use: request a training proposal. The broader Java Programming courses and learning guide shows related options.

Illustrative scenarios

The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.

  • Modeling an employee and department domain. A team might map departments, employees, and managers with @ManyToOne and @OneToMany. It would choose lazy or eager loading for each relationship, then use JPQL joins and constructor expressions to return only the fields a screen needs.
  • Concurrent edits to shared records. A team might add @Version fields so that two users editing the same record cannot silently overwrite each other. It would then decide where pessimistic locking is justified and where optimistic read or write locking is enough.
  • A flexible search screen. A team might build filters from optional user input using Criteria predicates and the generated metamodel, so that renaming an entity attribute causes a compile error and not a runtime failure. Range queries and a persistence facade keep that logic out of the UI layer.

AI coding assistants with JPA and Hibernate

AI coding assistants are useful for drafting entity classes and column annotations, writing first-pass JPQL, and generating boilerplate such as named queries, listeners, and validation constraint annotations. They are weaker where the correct answer depends on runtime behavior they cannot see:

  • Bidirectional relationships, where the owning side and cascade settings are easy to get subtly wrong.
  • Fetching strategy. Code can look correct and still trigger N+1 queries.
  • Transaction boundaries, detached entities, and merge semantics.
  • Locking and second-level cache settings, which depend on your concurrency requirements.
  • APIs or annotations that belong to a different JPA or Hibernate version than the project uses.

To verify the output, turn on SQL logging and count the statements a use case actually issues. Run tests against a real database, not mocks. Review every cascade, fetch, and lock setting by hand, and check the schema the mapping implies against the one you intend.

Frequently asked questions

What level is this course?

It is a general-level, four-day course for working Java developers. It moves from basic mapping through JPQL to advanced topics such as inheritance strategies, the Criteria API, locking, and caching.

What do I need to know beforehand?

A strong Java background is essential. Knowledge of relational database concepts and SQL is recommended. JDBC experience is a plus but not required.

What does the course cover?

Object/relational mapping and annotations, entity managers and persistence.xml, JPQL, advanced mappings, the Criteria API and metamodel, lifecycle events, JSR-303 validation with Hibernate Validator, and locking and caching. Exercises use Derby, which is bundled and pre-configured, or Oracle.

Can this be delivered privately for our team?

Yes. HSG delivers private training for organizations, onsite at your location or live online.

Can the content be customized?

Private courses can be customized, including to the technology versions your organization uses. Use the training proposal request to describe your environment and goals.

Training locations

JPA with Hibernate training across the U.S. and beyond.

We provide private JPA with Hibernate training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all JPA with Hibernate training locations

Train your team with HSG

Private, instructor-led training customized for your organization.

  • Onsite or live online delivery
  • Customized curriculum
  • For a single employee or an entire team
  • Flexible scheduling
  • Experienced instructors
Request Group Training

Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com

Ready to train your team?

Let's customize this training for your organization.

Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.