- 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
- Understand and use the complete capabilities of the Core module, such as lifecycle events, bean scopes, and the Spring API
- Use Springs ORM/JPA capabilities to integrate Spring and JPA and create Spring/JPA-based DAO types
- Understand and use Spring's transaction support, including its easy to use tx/aop XML configuration elements and TX-based annotations
- Integrate Spring with Java EE Web applications
- Understand the benefits of JPA
- Understand the JPA architecture
- Create JPA based applications
- 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
- Bidrectional and unidirectional
- 1-1, 1-N, N-N
- Use JPA's versioning support
- Map inheritance hierarchies using JPA
Hands-On
Minimum 50% hands-on labs
Supported Platforms
Spring 3, Spring 4, Eclipse, IBM RAD, others on request
Java Training Course Duration
5 Days
Java Training Course outline
Session 1: Introduction to Spring
- Overview of Spring Technology
- Challenges for Modern Applications
- Motivation for Spring, Spring Architecture
- The Spring Framework
- Spring Introduction
- Managing Beans
- Inversion of Control / IoC, Dependency Injection / DI
- Configuration Metadata Overview, Configuring Beans (XML)
- The Spring Container
- Overview of the Spring Container
- A Simple Spring Example
- ApplicationContext Overview
- ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, AnnotationConfigApplicationContext
- API and Usage
- Dependencies and Dependency Injection (DI)
- Examining Dependencies
- Dependency Inversion
- Dependency Injection (DI) in Spring - Basic Configuration and Usage
Session 2: Configuration in Depth
- Annotation Driven Configuration
- JSR 330 (@Named) and Spring (@Component) annotation styles
- @Named/@Component, @Inject/@Autowired, @Repository, @Service
- Configuring Beans and Autowiring with Annotations
- Enabling Annotations - context:component-scan
- Pros and Cons
- Java Based Configuration (@Configuration)
- Overview - code-centric Configuration
- @Configuration and @Bean
- Dependency Injection
- Resolving Dependencies on Other Beans, Injecting Configuration Classes
- Pros and Cons
- Integrating Configuration Types
- Choosing a Configuration Style
- Integrating Configuration Styles
- Importing: @Import and
- Scanning with @Configuration style
- Bean Scope and Lifecycle
- Bean Scope Defined - singleton, prototype, and Other Scopes
- Configuring Scope
- Bean Creation Lifecycle, Lifecycle Callbacks
- BeanPostProcessor, Event Handling
Session 3: Wiring in Depth
- Value Injection
- Configuring Value Properties, Property Conversions
- Externalizing Values in Properties Files
- Constructor Injection
- Constructor Injection Overview
- Configuration - @Configuration and XML
- p: and c: namespaces for XML configuration
- Qualifiers / Domain Specific Language (DSL)
- Limitations of Autowiring
- Qualifiers and DSL
- Creating and Using an Annotation-Based DSL for Bean Configuration
- Benefits of Qualifiers for Bean Configuration
- Profiles
- Profiles Overview
- Configuring Profiles (XML and @Configuration)
- Activating Profiles
- Overview of SpEL
Session 4: 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
- Logging Options (Provider based)
Session 5: 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 6: 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 7: Transaction (TX) Management
- Transaction Overview and Transactions in JPA
- Transaction Overview
- EntityTransaction API (including JTA and resource-local EntityManager)
- Spring Transaction Management
- Overview
- TransactionManagers
- Declarative Transactions and TX Propagation
- @Transactional and its settings
- XML Configured Transactions
- new <tx:*> elements, Configuring tx:advice, and tx:attributes
- Defining the TX advisor
Session 8: 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 9: 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, Table Structures
- Relationship Inverse - Owning Side
- Collection Types (List, Set, etc)
- Cascading Over Relationships (including orphanRemoval - JPA 2)
- @ManyToMany, @OneToOne
- Lazy and Eager Loading
- Queries Across Relationships (Inner Joins, Outer Joins, Fetch Joins)
- Entity Inheritance Mapping
- Overview
- Single Table Mapping
- Joined (Table per Subclass) Mapping
- Table per Concrete Class Mapping
- Pros and Cons
- Element Collections (JPA 2)
- Overview, Collections of Value Objects, @ElementCollection, @CollectionTable
- Using Element Collections
- Collections of Embeddables
Session 10: Introduction to 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 11: JPA Additional Topics
- Criteria Queries
- equals() and hashCode()
- Design Considerations