LearningPatterns: Your Global Source for Java Training, Mentoring, and Consulting
Home | About LearningPatterns | Our Services | Contact Us | Printer Friendly Link

Course Description:

Fast Track to Spring and JPA2

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 coming soon), 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.

The standard platform does all labs with the Eclipse IDE, and the lab instructions include detailed directions for setting up and using it. The course is available for all major development environments, including IBM RAD.

Course Information

Duration: 5 days

Hands-on: Minimum 50% hands-on

Supported Platforms: Spring 3, Spring 4, Eclipse, IBM RAD, others on request

Skills Gained:

Course Details:

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
Home | About LearningPatterns | Our Services | Legal | Contact Us       Copyright © LearningPatterns, Inc. All rights reserved.