Topics |
|
|
|
What you will learn |
|
After completing this course, the student should be able to:
|
|
Audience |
|
This course is designed for Java programmers and web application designers who have interest in learning how to persist data from Java applications to relational databases using the Java Persistence API (JPA) using IBM's Rational and WebSphere tools. | |
Prerequisites |
|
Intermediate level Java programming knowledge. Course WA1733 - Introduction to Java Using Rational Application Developer 7.5 satisfies this requirement |
|
Duration |
|
Three days |
Outline for Java Persistence (JPA) Programming using Rational Application Developer 7.5 Training
Chapter 1. Introduction to Rational Application Developer (RAD) v7.5
- The RAD 7.5 Product
- Eclipse Platform
- Rational Web Developer
- Rational Application Developer
- Key Features in RAD v7.5
- Views, Perspective, and Editor Areas
- Basic Operations with RAD Views and Perspectives
- The Java Perspective
- The Debug Perspective
- Navigator View
- Package Explorer
- Outline View
- Task and Problems View
- Build and Validation
- Import and Export Project
- Project Interchange Feature
- Code Completion, Templates and Snippets
- Searching
- Setup Compiler Class Path
- JRE Switching
- Migrating Workspace from RAD v6.0 or RAD v7.0
- Backward Compatibility with RAD v7.0
- References
- Summary
Chapter 2. Enterprise JavaBeans (EJBs) Overview
- Need for EJBs
- Distributed Computing
- Distributed Transaction
- Distributed Security
- What are EJBs?
- Main Characteristics of EJBs
- EJB Remote Method Call
- EJB Architecture Components
- EJB Client
- EJB JAR File
- EJB Container
- EJB Server
- Enterprise JavaBeans
- Session Beans
- Entity Beans
- Java Persistence API - Entities
- Message-Driven Beans (MDBs)
- EJB Specification
- Summary
Chapter 3. Stateless Session Beans
- Session Beans
- Stateless Session Bean
- Stateless Session Bean Pooling
- Stateless Session Bean Examples
- Stateful Session Bean
- Stateful Session Bean Examples
- Annotations
- Stateless Session Bean Components
- Example: Business Interface
- Example: Bean Class
- Alternative Example
- JNDI - Overview
- Example: The Client
- Business Interface Details
- Bean Class Details
- Session Bean Lifecycle
- Stateless Session Bean Lifecycle
- Summary
- Creating A Session Bean
- Creating An EJB Project
- The Client JAR
- EJB Projects
- Creating an EJB
- Creating the EJB
- Coding the Bean
- Updating Interfaces
- Dependencies
Chapter 4. Entities and Java Persistence API
- Data Persistence
- Java Persistence API
- Entities
- Session Beans Vs Entities
- Entities
- Persisting and Retrieving Data
- Accessing Entities
- EntityManager & Persistence Unit
- Persistence Context
- Entities - Example
- persistence.xml – Hibernate Provider
- persistence.xml – Open JPA Provider
- persistence.xml - Toplink
- Entity Instance Lifecycle
- Creating EntityManager in Session EJB
- Creating EntityManager in a Plain Java Class
- Working With the EntityManager Interface
- Transaction Basics
- Summary
- Creating Entities
- JPA Project
- Creating An Entity
- Generated Entity Class
- Code the Entity
- JPA Tooling
- Dependencies
Chapter 5. JPA Entity Lifecycle
- Entity Lifecycle
- When is an Entity Managed or Detached?
- Implementing the CRUD Pattern
- Accessing Entities Using Stateless Session Beans
- Inserting Data
- Retrieving Data
- Updating Data
- Deleting Data
- Merging Entities
- Merging Entities (example)
- Life-Cycle Callbacks
- Example: Internal callback
- External Callback Class
- Listener Class - Example
- Synchronizing with Databases
- Entity Lookup
- JPAQL (JPA Query Language)
- Summary
Chapter 6. Java Persistence Query Language (JPA QL)
- JPA Query Language
- Basic JPAQL Syntax
- Simple SELECT Examples
- Example of Using JPAQL
- The SELECT clause
- Reading Data from Code
- The WHERE Clause
- Example Using JPAQL from Session EJB
- Named Query
- Multiple Named Queries
- Bulk Updates
- Bulk Delete
- Running Native SQL Query
- Native SELECT Query
- Native SQL Delete and Insert
- Named Native Query
- Summary
Chapter 7. Basic Entity Relationships
- Relationship Between Entities
- Anatomy of a Relationship
- Foreign Key
- Example Schema
- One-to-One Unidirectional
- Creating Entity Instances
- Traversing the Relationship
- The Cascade Behavior
- One-to-One Bidirectional
- Maintaining Bidirectional Links
- Simplifying Bidirectional Links
- Traversing the Relationship
- Summary
Chapter 8. Complex Entity Relationships
- One-To-Many and Many-To-One
- Many-to-One Unidirectional
- Creating Entity Instances
- Traversing the Relationship
- Modeling One-to-Many
- Maintaining Bidirectional Links
- Creating Entity Instances
- Traversing the Relationship
- Many-to-Many
- Modeling Many-to-Many
- Maintaining Bidirectional Links
- Creating Entity Instances
- Traversing Relationship
- Unidirectional One-to-Many
- Modeling Unidirectional One-to-Many
- Creating Entity Instances
- Traversing the Relationship
- Relationship in JPA QL
- Fetching Optimizations
- Lazy vs. Eager Initialization
- Lazy Initialization
- Various Problems with Lazy Initialization
- Fetch Join Query
- Summary
Chapter 9. Entity Inheritance
- Inheritance
- Inheritance Example
- Inheritance and Entities
- Inheritance Strategies
- Inheritance Strategy 1: Single Table Per Class Hierarchy
- Single Table Per Class Hierarchy
- Table Structure: Single Table Per Class Hierarchy
- Pros and Cons
- Strategy 2: Table Per Concrete Class
- Table Per Concrete Class
- Table Per Concrete Class: JBoss Warning
- Table Per Concrete Class
- Table Structure: Table Per Concrete Class
- Table Per Concrete Class: Pros and Cons
- Strategy 3: Joined Subclasses
- Joined Subclasses
- Table Structure: Joined Subclasses
- Joined Subclasses: Pros and Cons
- Which Approach To Use?
- Summary
Chapter 10. Transactions in EJB
- Need for Transactions
- Transactions
- ACID Properties
- Transaction Components
- Distributed Transactions
- Distributed Transaction Components - Two Phase Commit
- Java Transaction API (JTA)
- Object Transaction
- EJB Transaction Basics
- Transaction Propagation
- Transaction Outcome
- Container Managed Transaction
- Transaction Attributes
- Container Managed Transaction Settings
- Interacting with Container Managed Transactions
- Container Managed Transaction – Example
- Transaction Attributes Support
- Bean Managed Transaction
- Using the JTA API
- Obtaining the UserTransaction
- Fine Points of Bean Managed Transaction
- Client Managed Transaction
- Transaction Isolation
- Summary
Chapter 11. JPA Design Patterns
- Data Transfer Object (DTO) Pattern
- JPA Entity as DTO
- Problem With JPA Entity as DTO
- Version Number pattern
- JPA and Version Number Pattern
- Primary Key Generation
- JPA and Primary Key Generation
- Fast Lane Pattern
- JPA and Fast Lane Pattern
- Summary