Oracle9iAS TopLink CMP for Users of IBM WebSphere Guide Release 2 (9.0.3) Part Number B10067-01 |
|
This document includes an example application that illustrates how to use EJB 1.1 entity beans with TopLink Container-Managed Persistence. The Single Bean Example shows how a single EJB bean can be made persistent using TopLink Container-Managed Persistence's container-managed persistence support. This example application illustrates simple direct-to-field mappings and introduces the basic steps required to deploy a bean.
If you are a new user, go through the single bean example, as well as the other examples included in the TopLink installation. These examples provide you with some hands-on experience with TopLink, and give you a better understanding of TopLink's power and usefulness.
TopLink Container-Managed Persistence is an extension of the TopLink for Java persistence framework. In addition to providing all of TopLink for Java's object-relational persistence facilities, TopLink Container-Managed Persistence also provides container-managed persistence (CMP) for Enterprise JavaBeans (EJBs) deployed in the IBM WebSphere server.
TopLink's CMP supports complex mappings from entity beans to relational database tables, and enables you to model relationships between beans, and between beans and regular Java objects. TopLink provides a rich set of querying options and allows query definition at the bean-level rather than the database level.
TopLink Container-Managed Persistence provides container-managed persistence and other object-relational mapping features for IBM WebSphere Server 4.0. Earlier versions of IBM WebSphere are not supported by this release.
TopLink Container-Managed Persistence supports the specification as defined by Sun Microsystems.
TopLink Container-Managed Persistence is an extension of the TopLink for Java product and shares all of its core functionality.
TopLink for Java provides an easy way to map a Java object model to a relational database. TopLink is a persistence framework that bridges the gap between objects and relational databases, and allows you to work at the object level.
TopLink supports the creation of a wide variety of Java applications. For building two-tier, three-tier, or n-tier applications; TopLink can be used within EJB and non-EJB environments. It can also be used within Java application servers or on its own.
If you are using TopLink for persistence requirements other than container-managed persistence (such as traditional two-, three-, or n-tier applications, non-EJB applications, or session bean-based applications), refer to the Oracle9iAS TopLink Foundation Library Guide. That document includes information on advanced TopLink features that are not included in this manual.
TopLink Mapping Workbench is a separate tool that provides a graphical method of configuring the descriptors and mappings of a project. It provides many checks to ensure that the descriptor settings are valid, and it also provides advanced functionality for accessing the database and creating a database schema.
The TopLink Mapping Workbench does not generate Java code during development, which would be unmanageable if the descriptors changed. Instead, it stores descriptor information in an XML deployment file, which can be read into a Java application using a TopLink method. When the application needs to be repackaged into a runtime, TopLink can then generate a .java
file from the XML file, eliminating the need for TopLink Mapping Workbench files at runtime.
The TopLink Mapping Workbench displays all of the project information for a given project, including classes and tables. Refer to the Oracle9iAS TopLink Mapping Workbench Reference Guide for more information on editing projects and descriptors using TopLink Mapping Workbench.
This section introduces the concepts required to use TopLink's container-managed persistence (CMP) facilities. It highlights the particular features available in TopLink Container-Managed Persistence that are not available in TopLink's core Java Foundation Library and explains any differences in the use of other core features.
This manual assumes that you have some familiarity with Enterprise JavaBeans (EJBs) and related concepts. This section provides an overview of some of the key terms that are encountered when discussing EJBs.
For more information about Enterprise JavaBeans, visit the Sun Microsystems EJB site at http://java.sun.com/products/ejb
.
To quote the Sun EJB specification, an enterprise bean implements a business task, or a business entity. Enterprise JavaBeans are server-side domain objects that fit into a standard component-based architecture for building enterprise applications using the Java language. They are Java objects that, when installed in an EJB server such as the IBM WebSphere Server, become distributed, transactional, and secure components. There are two kinds of EJBs: session beans and entity beans.
An EJB bean is said to reside within an EJB Container that in turn resides within an EJB Server. The exact distinction between container and server is not completely defined. In general, the server provides the bean with access to various services (transactions, security, and so on.) while the container provides the execution context for the bean by managing its life cycle.
The additional information required to install an EJB within its server is provided in the deployment descriptors for that bean. The deployment descriptors consists of a set of XML files that provide all of the required security, transaction, relationship, and persistence information for the bean.
Session beans represent a business operation, task, or process. Although the use of a session bean may involve database access, the beans are not in themselves persistent - they do not directly represent a database entry. Session beans may or may not retain conversational state; they may be stateful and retain client information between calls, or they may be stateless and only retain information within a single method call.
TopLink may be used with session beans to make the regular Java objects that they access persistent, or can be used to access TopLink persistent entity beans. Session beans may also act as wrappers to other legacy applications.
Entity beans represent a persistent data object - an object with durable state that exists from one access to the next. To accomplish this, the entity bean must be made persistent in a relational database, object database, or some other storage facility.
Two schemes exist for making entity beans persistent: bean-managed persistence (BMP) and container-managed persistence (CMP). BMP requires that the bean developer hand-code the methods that perform the persistence work. CMP uses information supplied by the developer or deployer to handle all aspects of persistence.
A Java object contains the following components:
Store primitive data such as integers, and also store simple Java types such as String and Date.
References to other TopLink-enabled classes. A TopLink-enabled class has a descriptor and can be stored in the database. Because TopLink-enabled classes can be stored in a database, they are called persistent classes.
Paths of execution that can be invoked in a Java environment. Methods are not stored in the database because they are static.
An entity bean has the following parts:
An instance of an entity bean class supplied by the developer of the bean. It is a regular Java object whose class implements the javax.ejb.EntityBean
interface. The bean instance has persistent state. The client application should never access the bean instance directly.
An instance of a generated class that implements the remote interface defined by the bean developer. This instance wraps the bean and all client interaction is made through this object. The EJBObject does not have persistent state.
An instance of a class that implements the home interface supplied by the bean developer. This instance is accessible from JNDI and provides all create and finder methods for the EJB. The EJBHome does not have persistent state.
An instance of the primary key class provided by the bean developer. The primary key is a serializable object whose fields match the primary key fields in the bean instance. Although the EJB Primary Key shares some data with the bean instance, it does not have persistent state. Note that as of EJB 1.1, it is not required that a bean have a separate primary key class when the key consists of a single field.
For more information about IBM WebSphere Server tools, APIs, or concepts, refer to the IBM WebSphere Server documentation.
For more information about the Enterprise JavaBeans standard, visit the Sun Microsystems EJB site at http://java.sun.com/products/ejb
.
|
Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|