Skip to main content

Instructor-led training

Introduction to Spring 5 and JPA2 Training in Gladstone, Missouri

This course includes coverage of all the core Spring 5 and JPA 2 capabilities, as well as the integration capabilities provided by Spring.

What you'll learn

This course includes coverage of all the core Spring 5 and JPA 2 capabilities, as well as the integration capabilities provided by Spring. It provides extensive coverage of using Spring and JPA together, as well as using Spring Boot for dependency management and creating JPA-based repositories using Spring Data. All capabilities are practiced via an extensive set of hands-on labs. Spring 5 provides an evolutionary advance of Spring's powerful capabilities. The course introduces these capabilities, as well as providing guidelines on when and how to use them. It includes coverage of the three main configuration styles: Java-based (@Configuration), annotation-based (@Component), and the traditional XML-based configuration that may still play an important role in existing and new projects. It uses Spring Boot capabilities for dependency management in many of the labs. The JPA material covers all basic JPA concepts, including mapping persistent classes, and using EntityManager and EntityManagerFactory to access and manipulate persistent entities. Querying with the Java Persistence Query Language (JPQL) is covered in depth, from basic queries to more advanced queries like eager queries using left joins. It also includes coverage of advanced concepts such as collections of value objects, relationships, and inheritance and polymorphic queries. This course is hands on with labs to reinforce all the important concepts. It will enable you to build working Spring/JPA applications and give you an understanding of the important concepts and technology in a very short time.

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Gladstone, Missouri 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

Basic Java

Course Outline

Session 1:  Introduction to Spring
Overview of Spring Technology
Motivation for Spring, Spring Architecture
The Spring Framework
Spring Introduction
Declaring and Managing Beans
ApplicationContexts - The Spring Container
XML and @Component/@Named Config
Dependencies and Dependency Injection (DI)
Examining Dependencies
Dependency Inversion / Dependency Injection (DI)
DI in Spring - XML and @Autowired
 
Session 2:  Configuration in Depth
Java Based Configuration (@Configuration)
Overview, @Configuration, @Bean
Dependency Injection
Resolving Dependencies
Integrating Configuration Types
XML and @Component Pros/Cons
@Configuration Pros/Cons
Choosing a Configuration Style
Integrating with @Import and <import>
Bean Scope and Lifecycle
Singleton, Prototype, and Other Scopes
Configuring Scope
Bean Lifecycle / Callbacks
Externalizing Properties
Properties Files
@PropertySource, property-placeholder
Using @Value
SpEL
Profiles
Overview and Configuration
Activating Profiles
 
Session 3:  Spring Boot Overview
maven and Spring
Spring Boot Structure
Spring POMs with Boot Parents
Spring Boot Starters
Other Capabilities
 
Session 4:  Spring Testing
Testing and JUnit Overview
Writing Tests - Test Classes, asserts, Naming Conventions
Running Tests - IDE, maven, ...
Test Fixtures - setup and teardown
Spring TestContext Framework
Overview
Configuration
Running Tests
 
Session 5: Introduction to Java Persistence API (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
Persistence Unit and EntityManager
Persisting to the DB, the EntityManager API
Persistence Units, Config, Persistence Context
Retrieving Persistent Entities with find()
More About Mappings
Default Mappings, @Basic, @Column
Field vs. Property Access
Temporal (Date/Time) Mappings
Java 8 Data/Time Mapping
equals() and hashCode()
Logging Options (Provider based)
 
Session 6: Spring/JPA Integration
Spring's DataSource Support
Managing the EntityManager (EM)
LocalContainerEntityManagerFactoryBean and Container-managed EMs
JEE and JNDI Lookup of the EM
Configuration and Vendor Adaptors
Creating a JPA Repository/DAO Bean - @PersistenceUnit, @PersistenceContext
 
Session 7: JPA Updates and Queries
Inserting Updating, and Deleting Entities
Querying and JPQL
Entity Based Queries, SELECT ,WHERE
Query Interface, Executing Queries, Generic Queries (JPA 2)
JPQL Operators, Expressions, and Parameters
Named Queries
Additional Query Capabilities - Projection and Aggregate Query, Embedded Objects
 
Session 8 Transactions
TX Overview and JPA Transactions
Spring's Declarative TX Management (REQUIRED, etc.)
@Transactional
TX Scope and Propagation
Pointcut-based Configuration of Transactions
 
Session 9: The JPA Persistence Lifecycle
The Persistence Lifecycle
JPA Entity States (New, Managed, Detached, Removed), and Entity State Diagram
Persistence Context - Lifespan, Propagation
Synchronization to the DB
Versioning and Optimistic Locking
Overview, Detached Instances
Versioning, @Version, Optimistic Locking
Lifecycle Callbacks
@PrePersist, @PostPersist, etc.
Entity Listeners, @EntityListeners
 
Session 10: Relationships
Relationships Overview: Object Relationships, Participants, Roles, Directionality, Cardinality
Relationship Mapping
Mapping Overview (1-1, 1-N, N-1, N-N)
Unidirectional and Bidirectional
@ManyToOne, @OneToMany, @ManyToMany, @OneToOne with Table Structures
Relationship Inverse - Owning Side
Collection Types (List, Set, etc)
Cascading, Lazy and Eager Loading
Queries Across Relationships (Inner Joins, Outer Joins, Fetch Joins)
Entity Inheritance Mapping
Overview
Single Table, Joined (Table per Subclass), Table per Concrete Class Mappings
Pros and Cons of Mapping Strategies
 
Session 11:  Spring Web Integration
Integrating Spring with Java EE Web Apps
ContextLoaderListener
WebApplicationContext
Using Spring beans in Wep app controller logic
Open EntityManager in View
Lazy Loading Issue in Web Apps
Open EntityManager in View Pattern
Using Spring's OpenEntityManagerInViewFilter/Interceptor
 
Session 12: Spring Data Introduction
Spring Data Overview
Overview and Architecture
Configuring Spring Data
Repositories and JPA Repositories
Using CrudRepository
Using Spring Data
Naming Conventions for Querying
Creating more Complex Queries
Query Configuration
 
Session 13: Additional Topics
Spring 5: Core Updates
JPA: Embedded Objects
JPA: Compound Primary Keys
JPA: Element Collections

What makes Spring and JPA hard to learn together

Basic Java is enough to read the code in this course. The harder part is that two frameworks now control behavior your code never states explicitly. Spring creates and wires your objects. JPA tracks and writes your data. Many mistakes only show up at startup or when a transaction commits.

The syllabus builds the layers in this order:

  • Container and configuration (sessions 1-3). Beans, ApplicationContexts and dependency injection come first, using XML, @Component and @Autowired. Then come @Configuration and @Bean, @Import, scopes, lifecycle callbacks, @Value, SpEL and profiles. A common misconception is that one style is correct. The course compares the pros and cons of each and how to combine them. Spring Boot parents and starters are introduced for dependency management.
  • Testing (session 4). JUnit fundamentals and the Spring TestContext Framework give you a way to check the later material.
  • JPA core (sessions 5, 7, 9). Entity mapping, the EntityManager and persistence units lead into JPQL. The entity states (new, managed, detached, removed) and persistence context synchronization are the hardest ideas. They explain why a change is saved without an explicit call, or is silently lost on a detached instance. @Version and optimistic locking build on the same concepts.
  • Integration and transactions (sessions 6, 8, 11). Container-managed EntityManagers, @PersistenceContext, @Transactional, propagation and the Open EntityManager in View pattern. Learners often assume @Transactional always applies. In practice, scope and propagation settings decide what actually happens.
  • Relationships and Spring Data (sessions 10, 12). Owning versus inverse sides, cascading, lazy versus eager loading, fetch joins, three inheritance strategies, then CrudRepository and query-by-naming-convention. Spring Data is easier to debug once you know the JPA behavior beneath it.

The course uses Java SE 8, including Java 8 date/time mapping. Java SE 8 is in Extended Support only, with support through December 2030.

Who it suits and what to take around it

This is an introductory, five-day course for Java developers who know the language but are new to Spring, JPA or both. It also suits teams that maintain XML-configured applications and need to understand @Configuration and annotation-based alternatives. Basic Java is the stated prerequisite. If your team needs a Java refresher first, start from the Java Programming courses and learning guide.

After this course, two directions follow naturally:

Organizations on other Java, Spring or JPA versions can ask for private training tailored to the versions they run. 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.

  • Consolidating configuration. A team might inherit an application with XML bean definitions and newer annotated classes side by side. The sessions on integrating configuration types, @Import and <import>, and profiles apply directly. They help the team externalize environment-specific properties and settle on one style.
  • Fixing a slow order screen. For example, a page that lists customers and their orders might trigger one query per row. Relationship mapping, lazy versus eager loading and fetch joins explain the cause. Open EntityManager in View explains why lazy loading failed or succeeded in the web tier. Rewriting the query with a fetch join is the fix.
  • Replacing hand-written DAOs. A team maintaining several JPA repository beans built on @PersistenceContext might move simple lookups to Spring Data. Naming-convention queries and CrudRepository cover those. Custom JPQL, named queries and @Transactional boundaries stay in place for complex cases, with TestContext-based tests guarding the change.

Using AI coding assistants with Spring and JPA

AI coding assistants are useful for boilerplate here. They can draft @Configuration classes, entity mappings with @Id and @Column, Spring Data repository interfaces and JUnit test skeletons. They can also explain unfamiliar XML configuration. Teams get the most from them after learning the concepts, because only then can they judge the output.

They tend to fail on behavior that depends on runtime state rather than syntax:

  • Version drift. Generated code may use APIs or configuration idioms from other framework releases than your project. Check imports and dependencies against your actual Spring and Java versions.
  • Transactions. Suggested @Transactional placement may ignore propagation and scope, or put the boundary where the proxy never applies it.
  • Entity design. Common errors include missing or wrong equals() and hashCode(), the wrong owning side on a bidirectional relationship, unsafe cascading, and eager fetching that hides N+1 queries.
  • Mixed configuration. Assistants may blend XML, component scanning and @Bean definitions so that beans are defined twice or the wrong profile is active.

To verify, turn on provider-based SQL logging and count the statements a use case issues. Write TestContext tests that load the real configuration and exercise transaction boundaries. Check entity state transitions explicitly, including detached instances and @Version conflicts. Review every generated mapping against the table structure it produces.

Frequently asked questions

What level is this course and what do I need beforehand?

It is introductory. The prerequisite is basic Java. No prior Spring or JPA experience is assumed, though some familiarity with relational databases and SQL helps with the JPQL and mapping sessions.

What does the course cover?

It covers Spring container and dependency injection, Java, annotation and XML configuration, scopes, profiles, Spring Boot dependency management, JUnit and the Spring TestContext Framework, JPA mapping and the EntityManager, JPQL, transactions, the entity lifecycle and optimistic locking, relationships and inheritance mapping, Spring web integration, and Spring Data repositories.

Does the course cover building web or REST applications?

It covers integrating Spring with Java EE web apps, including ContextLoaderListener, WebApplicationContext and Open EntityManager in View. It does not teach building REST services. A separate RESTful services course covers that.

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

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

Can the content be customized?

Yes. Private training can be tailored to the technology versions and topics an organization uses. Submit a training proposal request to discuss your needs.

Training locations

Introduction to Spring 5 and JPA2 training across the U.S. and beyond.

We provide private Introduction to Spring 5 and JPA2 training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all Introduction to Spring 5 and 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.