Skip to main content

Instructor-led training

Fast Track to Enterprise JavaBeans 3.0 (EJB3) and the Java Persistence API (JPA) Training in Butler, Pennsylvania

This course provides thorough coverage of the EJB3 technology - presented in a clear and effective manner.

What you'll learn

This course provides thorough coverage of the EJB3 technology - presented in a clear and effective manner. It starts with the basic concepts and APIs of EJB and then continues on with complex topics such as message driven beans and transactions. New concepts such as the use of annotations and the use of Dependency Injection to initialize references are covered in depth. The course also includes thorough coverage of managing persistence using the Java Persistence API (JPA).

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Butler, Pennsylvania 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 working knowledge of Java.

Course Outline

Introduction
Overview of EJB and Java Persistence API (JPA)
Goals of EJB, EJB in the Java EE architecture
EJB 3.0 Overview
Session Beans, Persistent Entities, Message Driven Beans
Lab: Server setup and introduction
 
Session Beans
Session Bean Overview
Services provided, Stateless and Stateful Beans
Defining a Session Bean - EJB 3 Annotations
The Bean Implementation, Remote and Local Business Interface
Packaging and Deployment
ejb-jar file, Deployment Descriptors in EJB 3
EAR file
The EJB Container
Lab: Creating a Stateless Session Bean
JNDI Overview
Distributed Naming and Lookup
Context and InitialContext
Using JNDI
Writing an EJB 3 Client
Client View of a Session Bean
PortableRemoteObject and Casting
Running the Client
Lab: Creating an EJB Client
 
Additional Capabilities
Resources and Dependency Injection
EJB referencing another EJB
Referencing Resources, Environment Entries
Connection Factories (DataSource and others)
Lab: Using Dependency Injection
Lab: Creating and Using Environment Entries
Session Bean Lifecycle and Interceptors
Stateless Session Bean Lifecycle
Business Method Interceptors,  InvocationContext, Lifecycle Callback Interceptors, Interceptor Classes
Lab: Working with Interceptors
Stateful Session Beans
Overview
Defining, Client Relationship
Lifecycle, Activation, Passivation
Lab: Stateful Session Beans
Timer Service
Overview and usage
 
Message-Driven Beans
Overview of Messaging Systems
Messaging, Loose Coupling
Pub/Sub, Point2Point
Overview of JMS API
Overview and Structure
ConnectionFactory and Destination
JMS Producer and Consumer Client example
JMS Messages
Message-Driven Beans (MDB)
Overview and Goals
@MessageDriven and MDB example
Configuring with activationConfig
State Diagram and Interceptors
Lab: Message Driven Beans
 
Transactions and Security
Overview of Transactions and Transactional Systems
ACID, Transaction Managers, Resource Managers
Transactions in EJB 3
Declarative Transaction Management
Transaction Attributes and Transactional Scope
Transaction Scenarios and Bean-Managed Tx
Lab: Working with Transactions
Security
Java EE Security Overview (Role-based)
@RolesAllowed, @PermitAll
Programmatic Security
Lab: Integrating EJB and Java EE Security
 
Exceptions
Exception Overview
Checked and Unchecked Exceptions
Exceptions in EJB 3
Application Exceptions, System Exceptions
EJB 3 Best Practices
When to Use, Coarse-Grained Business Interfaces, Session Façade, Transaction Guidelines, Clustering
 
Introduction to Java Persistence API (JPA)
Overview
Persistence Layers, Object-Relational Mapping (ORM), JDBC
JPA Overview
Mapping with JPA
Entities and @Entity, ids and @Id,
Generated Id Values
Basic Mapping Types
Lab: Mapping an Entity Class
EntityManager
Persisting to the DB, the EntityManager,
Persistence Units and Configuration
Injecting an EntityManager
Retrieving Persistent Entities
Lab: Using the EnityManager to persist and find an Entity
 
Updates and Queries
Inserting and Updating
Transient, Persistent, Detached, Removed
Persisting new Entities, Updating a Persistent Instance
Lab: Inserting and Updating an Entity
Querying and JPQL
Object Based Queries, Select statements, WHERE clause
Named Queries
Lab: Creating and Using JPQL Queries
Versioning and Optimistic Locking
Overview
Detached Entities
Creating Versioned Entities
Lab: Optimistic Locking
 
Entity Relationships
Relationships Overview
Object Relationships, Participants, Roles, Directionality, Cardinality
Relationship Mapping
Mapping Overview (1-1, 1-N, N-1, N-N)
Unidirectional and Bidirectional
Mapping One-One, One-Many
Join Columns
Relationship Inverses
Lab: Mapping Entity Relationships
Many-Many Relationships
Lazy and Eager Loading
Cascading
Queries Across Relationships (Inner Joins, Outer Joins, Fetch Joins)
Lab: Querying Across Relationships
Inheritance Mapping
Entity Inheritance
Single Table, Joined (Table per Subclass), Table per Concrete Class
Pros and Cons
Lab: Mapping Inheritance
 
Additional JPA Capabilities
Queries - Projection, Aggregate, Bulk Update/Delete
Embedded Objects
EJB 3 and Java SE
Best Practices
Primary Keys, Named Queries, Lazy/Eager Loading, Transactional Semantics, Encapsulation, Report Queries

What makes EJB 3 and JPA hard to master

The Java is rarely the obstacle. The difficulty is that the container does much of the work: it creates beans, injects references, starts and ends transactions, and enforces security before and after your code runs. Many mistakes surface only at deployment or at runtime. The syllabus builds up in layers.

  • Session beans and packaging first. Stateless and stateful beans, local and remote business interfaces, annotations, ejb-jar and EAR packaging, and JNDI lookup for a client. A common misconception is that a bean is an ordinary object you create with new.
  • Container services next. Dependency injection of EJBs, resources and environment entries, lifecycle callbacks, business-method interceptors with InvocationContext, stateful activation and passivation, and the timer service.
  • Messaging. Pub/sub versus point-to-point, the JMS API, and message-driven beans configured through @MessageDriven and activationConfig.
  • Transactions, security and exceptions. Declarative transaction attributes and scope, bean-managed transactions, @RolesAllowed and @PermitAll, and the difference between application and system exceptions. A frequent surprise is that the exception type changes whether a transaction rolls back.
  • JPA. Entity mapping, EntityManager, the transient/persistent/detached/removed states, JPQL, optimistic locking, relationships with lazy and eager loading, cascading and fetch joins, and inheritance mapping strategies. Detached entities and lazy loading are the usual sources of confusion.

Transactions are the hinge. Persistence behavior, messaging and security all depend on understanding transactional scope.

Who this course suits and what to take around it

The course is introductory and requires a working knowledge of Java. It suits developers and technical leads who build or maintain server-side Java applications on the EJB 3 programming model, and teams who need session beans, messaging and JPA in one program. Developers still building Java fundamentals can start from the Java Programming courses and learning guide.

For next steps, organizations running a later EJB and JPA release can look at Fast Track to Enterprise JavaBeans 3.1 (EJB3) and the Java Persistence API V2 (JPA2), which covers a later specification level. Teams that need to expose business logic over HTTP can follow with Developing RESTful Services Using Java.

Private training can be tailored to the versions your organization uses. Request a training proposal to discuss it.

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.

  • Maintaining an order-processing back end. A team might support an application where a stateless session bean coordinates a business operation across several entities. Declarative transaction attributes, application versus system exceptions and a coarse-grained session facade decide what is committed or rolled back when one step fails.
  • Decoupling a slow downstream step. A team might move notification or fulfillment work onto a JMS destination and consume it with a message-driven bean. Point-to-point versus pub/sub, activationConfig settings and transaction behavior determine delivery and retry.
  • Guarding concurrent updates to shared records. Two users might edit the same record from detached copies. Versioned entities and optimistic locking, together with the persistent/detached state model, show how a conflict is detected and where an update is lost.

AI coding assistants with EJB and JPA

AI coding assistants can draft the repetitive parts: entity classes with @Entity and @Id, business interfaces, simple JPQL and named queries, and boilerplate for a message-driven bean or JMS client. They also help explain unfamiliar deployment descriptors.

They fail where behavior depends on the container and on versions. Typical problems are annotations or lookup styles from a different framework or specification level, transaction attributes left implicit, activationConfig properties that suit a different server, and relationship mappings with the wrong owning side or cascade settings. An assistant may also generate queries that trigger many extra selects because of lazy loading, or return entities that are detached when the caller touches them. Security annotations can look right yet depend on role mapping that the generated code never sets up.

To verify:

  • Check generated code against the specification level and server your project actually uses.
  • Run it inside the container and inspect the SQL it emits.
  • Test rollback paths with both application and system exceptions.
  • Exercise optimistic-locking conflicts deliberately.
  • Test each role against secured methods.

Frequently asked questions

What level is this course?

It is introductory. It starts with basic EJB concepts and moves through messaging, transactions, security and JPA, with labs on each major topic.

What do I need to know beforehand?

A working knowledge of Java. No prior EJB, JMS or JPA experience is listed as a prerequisite.

What does the course cover?

Session beans (stateless and stateful), packaging, JNDI, dependency injection, interceptors, the timer service, JMS and message-driven beans, transactions, security, exceptions and EJB 3 best practices. The JPA portion covers entity mapping, EntityManager, JPQL, optimistic locking, relationships, inheritance mapping and embedded objects.

Can this be delivered privately, onsite or online?

Yes. HSG delivers private training for organizations at the client's 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

Fast Track to Enterprise JavaBeans 3.0 (EJB3) and the Java Persistence API (JPA) training across the U.S. and beyond.

We provide private Fast Track to Enterprise JavaBeans 3.0 (EJB3) and the Java Persistence API (JPA) training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all Fast Track to Enterprise JavaBeans 3.0 (EJB3) and the Java Persistence API (JPA) 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.