Skip to main content

Instructor-led training

Fast Track to Enterprise JavaBeans 3.1 (EJB3) and the JavaPersistenceAPIV2 (JPA2) Training in Strongsville, Ohio

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 2 (JPA2). This course provides additional coverage of JPA as compared to our Fast Track to EJB3 course.

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Strongsville, Ohio 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.1 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
JEE 6 WAR files and EJB
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
JEE 6 Portable EJB Lookup Names
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
Asynchronous Methods, Singleton Session Beans
Stateful Session Beans
Overview
Defining, Client Relationship
Lifecycle, Activation, Passivation
Lab: Stateful Session Beans
Timer Service
Programmatic Timers
Calendar-Based Timers
Lab: Working with Timers
 
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 V2 (JPA2 )
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 and Persistence Context
Persistence Unit and persistence.xml
Persisting to the DB, the EntityManager,
Injecting an EntityManager
Retrieving Persistent Entities
Lab: Using the EnityManager to persist and find an Entity
More About Mappings
Lab: Refining your Mappings
 
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
Criteria API
Lab: Criteria Querying
The Persistence Lifecycle - JPA Entity States, Lifecycle, and Persistence Context
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
Other Mapping Capabilities - Embedded Objects, Compound Primary Keys, and Element Collections
 
Additional JPA Capabilities
Queries - Projection, Aggregate, Bulk Update/Delete
Extended Persistence Contexts
XML Mapping Files
EJB and Java SE
Best Practices
Primary Keys, Named Queries, Lazy/Eager Loading, Transactional Semantics, Encapsulation, Report Queries

Why EJB 3.1 and JPA 2 take effort to master

The Java syntax is the easy part. Most of the difficulty comes from the container. You write annotated classes, and the application server decides when to create them, inject their dependencies, wrap their calls in transactions, pool them, passivate them and destroy them. Many bugs show up only at deployment or at runtime, not at compile time.

The syllabus builds in layers, and each layer depends on the one before it:

  • Session beans first. Stateless and stateful beans, local and remote business interfaces, packaging (ejb-jar, EAR, and EJB in a Java EE 6 WAR), JNDI and portable lookup names. Resource and EJB injection, lifecycle callbacks, interceptors, asynchronous methods, singletons and timers come after that.
  • Messaging. JMS concepts (publish/subscribe versus point-to-point, ConnectionFactory, Destination) come before message-driven beans and activationConfig. A common misconception is that an MDB is simply a bean called remotely. It is a message consumer with no client-visible interface.
  • Transactions, security and exceptions. Transaction attributes and scope, bean-managed transactions, @RolesAllowed and @PermitAll, and the difference between application and system exceptions. Exception type decides whether a transaction rolls back, which surprises many developers.
  • JPA 2. Entities and the persistence context, the entity states (transient, persistent, detached, removed), JPQL, the Criteria API, optimistic locking, relationship mapping, lazy versus eager loading, cascading, fetch joins and the three inheritance strategies.

The hardest JPA ideas are that an entity's behavior depends on its state and that a lazy association may not be loadable once the entity is detached. Neither is visible in the source code. Because EJB transactions control the persistence context, the two halves of the course also reinforce each other.

Who it suits and what to take around it

The stated prerequisite is a working knowledge of Java. The course is introductory for EJB and JPA, not for Java itself. It suits developers who maintain or build server-side Java applications and training managers who need a team productive on session beans, messaging, transactions and persistence in one five-day block. The syllabus uses Java EE 6 packaging and EJB 3.1 features such as singletons, asynchronous methods and calendar-based timers. It is a natural fit for teams supporting systems at that level. Developers who need Java fundamentals first can start from the Java Programming courses and learning guide.

Organizations on a later Java EE level can compare the Fast Track to EJB 3.2 (JEE 7 level) and JPA2 course. Private training can also be tailored to the versions a team actually runs, and you can request a training proposal to discuss that.

Once the business layer works, the Developing RESTful Services Using Java course is a sensible next step for teams that need to expose it over HTTP.

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.

  • Order intake with reliable hand-off. A team might accept orders through a stateless session bean and publish a message to a queue. A message-driven bean would then handle fulfillment, so the two sides stay loosely coupled. Declarative transaction attributes decide whether the database write and the message send commit or roll back together.
  • Scheduled maintenance work. For example, a nightly cleanup or report job could use a calendar-based timer. A singleton session bean could hold shared state, and an asynchronous method could keep a long step from blocking the caller.
  • A domain model with concurrent editors. A team might map customers, accounts and a class hierarchy with one-to-many and many-to-many relationships, and choose single-table or joined inheritance. They could add a version attribute for optimistic locking so that two users editing the same detached entity do not silently overwrite each other. Fetch joins would keep a report query from issuing one query per row.

AI coding assistants with EJB and JPA

AI coding assistants are useful for boilerplate here: entity classes with @Entity and @Id, simple JPQL and Criteria queries, persistence.xml drafts, and first-pass session bean skeletons.

They tend to fail where behavior depends on the container or on runtime state:

  • Transaction semantics. Generated code often ignores which transaction attribute applies, or lets an exception type decide rollback by accident.
  • Lazy loading. Code that works inside a transaction can fail on a detached entity, or hide an N+1 query pattern that only shows up with real data volumes.
  • Platform mismatch. Suggestions may mix annotations, package namespaces or configuration styles from a different Java EE generation or from Spring, so they must match the target server and Java version.
  • MDB and security configuration. Activation properties and role mappings are server-specific, and assistants often invent plausible but wrong values.

To verify, deploy to a real container and read the logged SQL. Write tests that cross transaction boundaries and cover rollback, detachment and concurrent updates. Review every generated annotation against the behavior you intend, and have a person review security annotations such as @RolesAllowed.

Frequently asked questions

What level is this course?

It is introductory to EJB and JPA but runs five days and covers a broad range, from session beans and JNDI through message-driven beans, transactions, security and JPA 2 relationships, inheritance and locking. It assumes you already program in Java.

What do I need to know beforehand?

A working knowledge of Java. No prior EJB, JMS or persistence experience is assumed, since the syllabus starts with the goals of EJB and the basic session bean model.

What does the course cover?

Session beans (stateless, stateful, singleton), packaging and deployment, JNDI and client lookup, dependency injection, interceptors, timers, JMS and message-driven beans, transactions, security and exceptions. It then covers JPA 2: mapping, EntityManager, JPQL, the Criteria API, optimistic locking, relationships, inheritance mapping and best practices. Most topics have hands-on labs.

Can this be delivered privately for our team, onsite or online?

Yes. HSG delivers private training for organizations either onsite at the client's location or live online.

Can the content be customized?

Private training can be customized, including tailoring to the technology versions your organization uses. You can request a training proposal to discuss your environment and priorities.

Training locations

Fast Track to Enterprise JavaBeans 3.1 (EJB3) and the JavaPersistenceAPIV2 (JPA2) training across the U.S. and beyond.

We provide private Fast Track to Enterprise JavaBeans 3.1 (EJB3) and the JavaPersistenceAPIV2 (JPA2) training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all Fast Track to Enterprise JavaBeans 3.1 (EJB3) and the JavaPersistenceAPIV2 (JPA2) 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.