Introduction to Spring 4 and JPA 2

This course is also available for Spring 5: Introduction to Spring 5 and JPA 2.

Spring is a lightweight Java framework for building enterprise applications. Its Core module allows you to manage the lifecycle of your objects and the dependencies between them via configuration metadata (either XML or annotations) and Dependency Injection / Inversion of Control.Its advanced capabilities provide support for JDBC and persistence frameworks like JPA2 (DAO and ORM modules), as well as integration with Java EE Web technologies.

The Java Persistence API (JPA) is is a Java standard object/relational (OR) persistence and query service for Java. JPA supports a POJO (Plain Old Java Object) based model using annotations which lets you develop persistent classes following common Java idioms. It supports entity relationships, inheritance, polymorphism, composition, and much more. .

This course, available for Spring 3 (and Spring 4), includes coverage of all the core Spring and JPA capabilities, as well as the integration capabilities provided by Spring. It provides extensive coverage of using Spring and JPA together, as well as all the core concepts of Spring and JPA themselves. All capabilities are practiced via an extensive set of hands-on labs.

The course starts with the basics of Spring and in-depth coverage of using the powerful capabilities of the Core module to reduce coupling and increase the flexibility and ease of maintenance and testing of your applications. It goes on to cover the basics of using Spring to simplify the creation of a persistence layer using its JPA integration capabilities.

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.


Public Classes: Delivered live online via WebEx and guaranteed to run . Join from anywhere!

Private Classes: Delivered at your offices , or any other location of your choice.

  1. Understand the core principles of Spring, and of Dependency Injection (DI)/Inversion of Control
  2. Use the Spring Core module and DI to configure and wire application objects (beans) together
  3. Understand and use the complete capabilities of the Core module, such as lifecycle events, bean scopes, and the Spring API
  4. Use Springs ORM/JPA capabilities to integrate Spring and JPA and create Spring/JPA-based DAO types
  5. Understand and use Spring's transaction support, including its easy to use tx/aop XML configuration elements and TX-based annotations
  6. Integrate Spring with Java EE Web applications
  7. Understand the benefits of JPA
  8. Understand the JPA architecture
  9. Create JPA based applications
  10. Understand and use JPA mapping to map persistent objects to the database
  11. Work with JPA queries and JPQL
  12. Understand and work with collections and associations
    1. Value and Entity Types
    2. Bidrectional and unidirectional
    3. 1-1, 1-N, N-N
  13. Use JPA's versioning support
  14. Map inheritance hierarchies using JPA
  1. Introduction to Spring
    1. Overview of Spring Technology
      1. Challenges for Modern Applications
      2. Motivation for Spring, Spring Architecture
      3. The Spring Framework
    2. Spring Introduction
      1. Managing Beans
      2. Inversion of Control / IoC, Dependency Injection / DI
      3. Configuration Metadata Overview, Configuring Beans (XML)
    3. The Spring Container
      1. Overview of the Spring Container
      2. A Simple Spring Example
      3. ApplicationContext Overview
      4. ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, AnnotationConfigApplicationContext
      5. API and Usage
    4. Dependencies and Dependency Injection (DI)
      1. Examining Dependencies
      2. Dependency Inversion
      3. Dependency Injection (DI) in Spring - Basic Configuration and Usage
  2. Configuration in Depth
    1. Annotation Driven Configuration
      1. JSR 330 (@Named) and Spring (@Component) annotation styles
      2. @Named/@Component, @Inject/@Autowired, @Repository, @Service
      3. Configuring Beans and Autowiring with Annotations
      4. Enabling Annotations - context:component-scan
      5. Pros and Cons
    2. Java Based Configuration (@Configuration)
      1. Overview - code-centric Configuration
      2. @Configuration and @Bean
      3. Dependency Injection
      4. Resolving Dependencies on Other Beans, Injecting Configuration Classes
      5. Pros and Cons
    3. Integrating Configuration Types
      1. Choosing a Configuration Style
      2. Integrating Configuration Styles
      3. Importing: @Import and
      4. Scanning with @Configuration style
    4. Bean Scope and Lifecycle
      1. Bean Scope Defined - singleton, prototype, and Other Scopes
      2. Configuring Scope
      3. Bean Creation Lifecycle, Lifecycle Callbacks
      4. BeanPostProcessor, Event Handling
  3. Wiring in Depth
    1. Value Injection
      1. Configuring Value Properties, Property Conversions
      2. Externalizing Values in Properties Files
    2. Constructor Injection
      1. Constructor Injection Overview
      2. Configuration - @Configuration and XML
      3. p: and c: namespaces for XML configuration
    3. Qualifiers / Domain Specific Language (DSL)
      1. Limitations of Autowiring
      2. Qualifiers and DSL
      3. Creating and Using an Annotation-Based DSL for Bean Configuration
      4. Benefits of Qualifiers for Bean Configuration
    4. Profiles
      1. Profiles Overview
      2. Configuring Profiles (XML and @Configuration)
      3. Activating Profiles
      4. Overview of SpEL
  4. Introduction to Java Persistence API (JPA2)
    1. Overview
      1. Persistence Layers, Object-Relational Mapping (ORM), JDBC
      2. JPA Overview
    2. Mapping with JPA
      1. Entities and @Entity, ids and @Id,
      2. Generated Id Values
      3. Basic Mapping Types
    3. Persistence Unit and EntityManager
      1. Persisting to the DB, the EntityManager API
      2. Persistence Units, Config, Persistence Context
      3. Retrieving Persistent Entities with find()
    4. More About Mappings
      1. Default Mappings, @Basic, @Column
      2. Field vs. Property Access
      3. Temporal (Date/Time) Mappings
    5. Logging Options (Provider based)
  5. Spring/JPA Integration
    1. Spring's DataSource Support
    2. Managing the EntityManager (EM)
    3. LocalContainerEntityManagerFactoryBean and Container-managed EMs
    4. JEE and JNDI Lookup of the EM
    5. Configuration and Vendor Adaptors
    6. Creating a JPA Repository/DAO Bean - @PersistenceUnit, @PersistenceContext
  6. Updates and Queries
    1. Inserting Updating, and Deleting Entities
    2. Querying and JPQL
      1. Entity Based Queries, SELECT ,WHERE
      2. Query Interface, Executing Queries, Generic Queries (JPA 2)
      3. JPQL Operators, Expressions, and Parameters
      4. Named Queries
    3. Additional Query Capabilities - Projection and Aggregate Query, Embedded Objects
  7. Transaction (TX) Management
    1. Transaction Overview and Transactions in JPA
      1. Transaction Overview
      2. EntityTransaction API (including JTA and resource-local EntityManager)
    2. Spring Transaction Management
      1. Overview
      2. TransactionManagers
      3. Declarative Transactions and TX Propagation
      4. @Transactional and its settings
    3. XML Configured Transactions
      1. new <tx:*> elements, Configuring tx:advice, and tx:attributes
      2. Defining the TX advisor
  8. The JPA Persistence Lifecycle
    1. The Persistence Lifecycle
      1. JPA Entity States (New, Managed, Detached, Removed), and Entity State Diagram
      2. Persistence Context - Lifespan, Propagation
      3. Synchronization to the DB
    2. Versioning and Optimistic Locking
      1. Overview, Detached Instances
      2. Versioning, @Version, Optimistic Locking
    3. Lifecycle Callbacks
      1. @PrePersist, @PostPersist, etc.
      2. Entity Listeners, @EntityListeners
  9. Relationships
    1. Relationships Overview: Object Relationships, Participants, Roles, Directionality, Cardinality
    2. Relationship Mapping
      1. Mapping Overview (1-1, 1-N, N-1, N-N)
      2. Unidirectional and Bidirectional
      3. @ManyToOne, @OneToMany, Table Structures
      4. Relationship Inverse - Owning Side
      5. Collection Types (List, Set, etc)
      6. Cascading Over Relationships (including orphanRemoval - JPA 2)
      7. @ManyToMany, @OneToOne
      8. Lazy and Eager Loading
      9. Queries Across Relationships (Inner Joins, Outer Joins, Fetch Joins)
    3. Entity Inheritance Mapping
      1. Overview
      2. Single Table Mapping
      3. Joined (Table per Subclass) Mapping
      4. Table per Concrete Class Mapping
      5. Pros and Cons
    4. Element Collections (JPA 2)
      1. Overview, Collections of Value Objects, @ElementCollection, @CollectionTable
      2. Using Element Collections
      3. Collections of Embeddables
  10. Introduction to Spring Web Integration
    1. Integrating Spring with Java EE Web Apps
      1. ContextLoaderListener
      2. WebApplicationContext
      3. Using Spring beans in Wep app controller logic
    2. Open EntityManager in View
      1. Lazy Loading Issue in Web Apps
      2. Open EntityManager in View Pattern
      3. Using Spring's OpenEntityManagerInViewFilter/Interceptor
  11. JPA Additional Topics
    1. Criteria Queries
    2. equals() and hashCode()
    3. Design Considerations
Class Materials

Each student in our Live Online and our Onsite classes receives a comprehensive set of materials, including course notes and all the class examples.

Class Prerequisites

Experience in the following is required for this Spring class:

  • Good practical Java programming skills, including use of inheritance and interfaces.
  • Some familiarity with SQL and databases.

Training for your Team

Length: 5 Days
  • Private Class for your Team
  • Online or On-location
  • Customizable
  • Expert Instructors

What people say about our training

I've taken online courses elsewhere and this experience ranks the best so far. Awesome instructor.
Stephen Hopkins
Electronic Arts Canada
Knowledgeable instructor who used tools other than just the database tool and WebEx (such as the whiteboard) that appeal to the right side of my brain. The graphic representation of tables via drawing with colors provided me with an easier learning experience and a more complete way to remember dry material.
Nancy Medina
Prem Valluru
Shaw Industries
I appreciated the small class size. It felt like a one-on-one experience. I was impressed with how smoothly my class went.
Matt Ingold
Bechtel Plant Machinery, Inc.

No cancelation for low enrollment

Certified Microsoft Partner

Registered Education Provider (R.E.P.)

GSA schedule pricing


Students who have taken Instructor-led Training


Organizations who trust Webucator for their Instructor-led training needs


Satisfaction guarantee and retake option


Students rated our trainers 9.29 out of 10 based on 29,928 reviews

Contact Us or call 1-877-932-8228