The J2EETM Tutorial
Home
TOC
Index
PREV TOP NEXT Search
Feedback

Container-Managed Persistence Examples

Dale Green

An entity bean with container-managed persistence offers important advantages to the bean developer. First, the EJB container handles all database storage and retrieval calls. Second, the container manages the relationships between the entity beans. Because of these services, you don't have to code the database access calls in the entity bean. Instead, you specify settings in the bean's deployment descriptor. Not only does this approach save you time, but it makes the bean portable across various database servers.

This chapter focuses on the source code and deployment settings for an example called RosterApp, an application that features entity beans with container-managed persistence. If you are unfamiliar with the terms and concepts mentioned in this chapter, please consult the section Container-Managed Persistence.

In This Chapter

Overview of the RosterApp Application
The PlayerEJB Code
Entity Bean Class
Local Home Interface
Local Interface
A Guided Tour of the RosterApp Settings
RosterApp
RosterClient
RosterJAR
TeamJAR
Method Invocations in RosterApp
Creating a Player
Adding a Player To a Team
Removing a Player
Dropping a Player From a Team
Getting the Players Of a Team
Getting a Copy of a Team's Players
Finding the Players By Position
Getting the Sports of a Player
Running the RosterApp Example
Setting Up
Deploying the Application
Running the Client
Deploytool Tips for Entity Beans With Container-Managed Persistence
Specifying the Bean's Type
Selecting the Persistent Fields and Abstract Schema Name
Defining EJB QL Queries for Finder and Select Methods
Generating SQL and Specifying Table Creation
Specifying the Database JNDI Name, User Name, and Password
Defining Relationships
Primary Keys for Container-Managed Persistence
The Primary Key Class
Primary Keys in the Entity Bean Class
Generating Primary Key Values
Home
TOC
Index
PREV TOP NEXT Search
Feedback