Spring Framework Training Overview
This Spring 5 and JPA2 training teaches students how to use Spring Boot for dependency management and to create JPA-based repositories using Spring Data. Students learn the three main configuration styles: Java-based (@Configuration), annotation-based (@Component), and the traditional XML-based configuration.
Location and Pricing
Accelebrate offers instructor-led enterprise training for groups of 3 or more online or at your site. Most Accelebrate classes can be flexibly scheduled for your group, including delivery in half-day segments across a week or set of weeks. To receive a customized proposal and price quote for private corporate training on-site or online, please contact us.
In addition, some courses are available as live, online classes for individuals.
See a schedule of online courses.
Objectives
- Understand the core principles of Spring, and of Dependency Injection (DI) / Inversion of Control
- Use the Spring Core module and DI to configure and wire application objects (beans) together
- Know the different types of metadata (XML, annotations/@Component, and Java Configuration/@Configuration), and how and when to use them
- Understand and use the complete capabilities of the Core module, such as lifecycle events, bean scopes, and the Spring API
- Use Spring Boot to simplify dependency management and configuration
- Understand the benefits of JPA and the JPA Architecture
- Create JPA based applications
- Work with the ORM (Object-Relational Mapping) module to integrate Spring with JPA.
- Understand and use Spring's transaction support, including the easy-to-use Java annotation support, as well as the tx/aop XML configuration elements
- Understand and use JPA mapping to map persistent objects to the database
- Work with JPA queries and JPQL
- Understand and work with collections and associations (Value and entity types, unidirectional, bidirectional, 1-1, 1-N, N-N
- Use JPA's versioning support
- Map inheritance hierarchies using JPA
- Integrate Spring/JPA with Java EE Web applications
- Use Spring Data to automatically generate JPA-based repositories with auto-generated queries
Prerequisites
All attendees must have at least one year of full-time Java and JSP development experience. Prior experience with servlets and JSP is recommended but not required.
Outline
Expand All | Collapse All
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
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
Spring Boot Overview
- maven and Spring
- Spring Boot Structure
- Spring POMs with Boot Parents
- Spring Boot Starters
- Other Capabilities
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
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)
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
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
Transactions
- TX Overview and JPA Transactions
- Spring's Declarative TX Management (REQUIRED, etc.)
- @Transactional
- TX Scope and Propagation
- Pointcut-based Configuration of Transactions
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
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
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
Spring Data Introduction
- 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
Additional Topics
- Spring 5: Core Updates
- JPA: Embedded Objects
- JPA: Compound Primary Keys
- JPA: Element Collections
Conclusion
Training Materials:
All attendees receive comprehensive courseware covering all subjects in the course.
Software Requirements:
- JDK 8 or later (required for Spring 5)
- IntelliJ IDEA, Eclipse with Spring Tools, or another IDE of your choice
- Related lab files that Accelebrate provides
- Other free software - please contact us if you have purchased this class.