Presented by developerWorks, your source for great tutorials
ibm.com/developerWorks
email
Although the CMP field definition in the deployment descriptor is specified by the EJB
specification, there is not a standard way to map entity beans to SQL tables and CMP
fields to SQL columns. (I hope this is addressed in the next version of the EJB
Specification.)
The mapping is left up to the discretion of the EJB container implementation. This will
likely change in a future release of EJB. Since the implementation of the reference
J2EE application server does not allow easy mapping from entity beans to SQL tables,
the examples use the mappings defined by using the
deploytool
.
You will not have to perform mappings. The mappings are provided by the included Ant
build scripts.
Defining the primary key field in the deployment
descriptor
Every entity bean must have a primary key. The
UserBean
s primary key is the e mail
CMP field. Thus, primary key field and its type must be specified in the deployment
descriptor just like any entity bean as follows:
java.lang.String
email
Deployment descriptor
The rest of the deployment descriptor is what you would expect. Notice that the
deployment descriptor uses
2.x
to denote the
version of CMP desired. This was added to accommodate EJB containers that support
both CMP 1.0 and CMP 2.0 style container managed persistence. The complete
deployment descriptor is as follows:
Listing 1: Deployment descriptor for UserBean
Introducing EJB CMP/CMR, Part 1 of 2
Page 15 of 48
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved