blob: 1364fc64c986bef1bb005bd4a5e0218afc8a7655 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2005, v.4002-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<!-- /******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
************************************************************************************/ -->
<link href="../../org.eclipse.wst.doc.user/common.css" rel="stylesheet" type="text/css"/><?Pub Caret?>
<title>Creating container-managed persistence (CMP) entity beans with XDoclet
annotation support</title>
</head>
<body id="temessb"><a name="temessb"><!-- --></a> <h1 class="topictitle1">Creating
container-managed persistence (CMP) entity beans with XDoclet annotation support</h1> <div><p>You
can use a wizard to create a CMP entity bean and add it to your project.</p> <div
class="p"><p>Before you can create an enterprise bean, you must:</p> <ul>
<li>Define an EJB project to contain the enterprise bean. See <a href="tecrtpro.html"
title="An EJB project is used to organize the resources contained in an EJB module.">Creating
EJB projects</a></li>
<li>Install XDoclet annotation support and enable it. See <a href="txdocletconf.html"
title="To use XDoclet annotation support, or to create enterprise beans, XDoclet must be installed on your system and configured to work with the workbench."
>Configuring XDoclet annotation support</a></li>
</ul> </div> <div class="section"><p>To create a CMP entity bean:</p> </div> <ol>
<li class="stepexpand"><span>In the J2EE perspective, click <strong>File &gt;
New &gt; Other &gt; EJB &gt; XDoclet Enterprise JavaBean</strong>. The Create
an Enterprise JavaBean wizard appears.</span></li>
<li class="stepexpand"><span>Select <strong>ContainerManagedEntityBean</strong>.</span></li>
<li class="stepexpand"><span>Click <strong>Next</strong>.</span></li>
<li class="stepexpand"><span>Select the <strong>Project</strong> that will
contain the new bean. </span></li>
<li class="stepexpand"><span>In the <strong>Folder</strong> field, select
the folder for the new bean. </span></li>
<li class="stepexpand"><span>In the <strong>Java package</strong> field, enter
the package name for the new bean. </span></li>
<li class="stepexpand"><span>In the <strong>Class name</strong> field, type
a name for the enterprise bean. By convention, bean names should begin with
an uppercase letter. </span> <div class="note"><span class="notetitle">Note:</span> You
can use Unicode characters for the bean name, but Unicode characters are not
supported for enterprise bean packages and classes associated with enterprise
beans.</div> </li>
<li class="stepexpand"><span>Change the <strong>Superclass</strong> for the
bean if you want it to inherit from a class other than <samp class="codeph">java.lang.Object</samp> .</span></li>
<li class="stepexpand"><span>Click <strong>Next</strong>.</span></li>
<li class="stepexpand"><span>Provide an <strong>EJB Name</strong> for the
bean. This is the name of the enterprise bean class. </span></li>
<li class="stepexpand"><span>Provide a <strong>Schema</strong> name to specify
the abstract schema of the bean.</span></li>
<li class="stepexpand"><span>Provide a <strong>Display Name</strong> for the
bean. This is a short name for the enterprise bean that is used by tools.</span></li>
<li class="stepexpand"><span>Provide a text <strong>Description</strong> for
the bean.</span></li>
<li class="stepexpand"><span>Select a <strong>CMP Version</strong> for the
new bean:</span><ul>
<li><strong>1.x</strong> specifies you are adding the bean to an EJB 1.0 or
later project.</li>
<li><strong>2.x</strong> specifies you are adding the bean to an EJB 2.0 or
later project.</li>
</ul> </li>
<li class="stepexpand"><span>Select a <strong>Usecase</strong> for the new
bean:</span><ul>
<li><strong>Import attributes from table</strong> specifies that the CMP entity
bean attributes will be imported from a database table. Click <strong>Next</strong>.<ol
type="a">
<li>Perform one of the following:<ul>
<li>To select an available connection definition, click a connection in the <strong>Available
Connection Definitions</strong> list. Click <strong>Next</strong>.</li>
<li>To create a new JDBC connection definition, click <strong>New</strong>.
In the <strong>Connection Parameters</strong> window, specify the required
JDBC connection parameters on the Connection parameters page of the New Connection
wizard. Select a database manager, a JDBC driver, and specify other connection
details. To specify JDBC connection filters, clear the <strong>Disable filter</strong> check
box and specify appropriate connection filters. Click <strong>Finish</strong>.</li>
</ul> </li>
</ol> </li>
<li><strong>Define new attributes</strong> specifies that the CMP entity bean
attributes will be user-defined. Click <strong>Next</strong>.<ol type="a">
<li>To create a CMP attribute for the entity bean, click <strong>Add</strong>.</li>
<li>To specify a name for the attribute, click in the <strong>Name</strong> field
and enter a name.</li>
<li>To specify a type for the attribute, click in the <strong>Type</strong> field
and enter a type.</li>
<li>To make the attribute a key field for the entity bean, select the <strong>Primary
Key</strong> check box.</li>
<li>To specify a table name for the entity bean, enter a name in the <strong>Table</strong> field.</li>
<li>To add more attributes, repeat procedures a to d.</li>
</ol> </li>
</ul> </li>
<li class="stepexpand"><span>Click <strong>Next</strong>.</span></li>
<li class="stepexpand"><span>Select the type of <strong>Modifiers</strong> to
use for the class. Choices are <strong>Public</strong>, <strong>Abstract</strong>,
and <strong>Final</strong>. </span></li>
<li class="stepexpand"><span>Select the <strong>Interfaces</strong> you want
the bean to implement:</span> <ul>
<li>Click the <strong>Add</strong> button to open the Type Selection dialog
box where you can select the interface that you want to implement. </li>
<li>If you added an interface that you no longer want to implement, select
the interface in the list and click <strong>Remove</strong>.</li>
</ul> </li>
<li class="stepexpand"><span>Select the method stubs that you want the wizard
to create. Choices include <strong>main</strong>, <strong>Inherited abstract
methods</strong>, and <strong>Constructors from the superclass</strong>.</span></li>
<li class="stepexpand"><span>Click <strong>Finish</strong>. The new bean is
added to the specified EJB project.</span></li>
</ol> </div> </body>
</html>
<?Pub *0000006991?>