ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
Section 3. Example 1: Creating the entity bean
CMP Fundamentals: An overview by example
The first example introduces you to the fundamental concepts of CMP including the
following:
defining CMP fields in the deployment descriptor
how to reference an enterprise bean from another bean,
how to reference an enterprise bean from a client.
In this example, I will create three things:
An entity bean (
UserBean
) that uses container managed persistence.
A session bean that accesses the entity bean (
UserManagementBean
).
A client that access the entity bean (Section2Client).
UserBean
(entity bean)
The
UserBean
represents a user in the system. The
UserBean
, like all enterprise
beans, needs three Java source files as follows: a home, an interface, and an
implementation. Thus, you need to define the following code:
Local Interface (
LocalUser
)
Local Home Interface (
LocalUserHome
)
Entity Bean Class (
UserBean
)
The source code for this example can be found at
cmpCmr/section2/src
. To compile
this example go to
cmpCmr/section2
and type
ant
at the command prompt. A sample
.ear
will be created in the
cmpCmr/section2/final
directory. If you are using the
reference implementation, you can deploy this
.ear
with the
deploytool
program.
Page 12 of 48
Introducing EJB CMP/CMR, Part 1 of 2
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