⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmp8.html

📁 j2eePDF格式的电子书
💻 HTML
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>deploytool Tips for Entity Beans with Container-Managed Persistence</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="CMP7.html" />    <link rel="Next" href="MDB.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="CMP7.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="MDB.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp80771"> </a><h2 class="pHeading1">deploytool Tips for Entity Beans with Container-Managed Persistence</h2><a name="wp80776"> </a><p class="pBody">Chapter&nbsp;<a  href="EJB.html#wp80468">19</a> covered the basic steps for building and packaging enterprise beans. This section highlights the tasks in <code class="cCode">deploytool</code> that are needed for entity beans with container-managed persistence. The examples referenced in this section are from <a  href="CMP6.html#wp83001">A Guided Tour of the RosterApp Settings</a>.</p><a name="wp80786"> </a><h3 class="pHeading2">Selecting the Persistent Fields and Abstract Schema Name</h3><a name="wp80787"> </a><p class="pBody">In the Entity tab of the enterprise bean, enter the field information and the abstract schema name.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp80788"> </a><div class="pSmartList1"><li>In the Fields To Be Persisted list, select the fields that will be saved in the database. The names of the persistent fields are determined by the access methods defined in the entity bean code. Be sure to not select container-managed relationship fields.</li></div><a name="wp80789"> </a><div class="pSmartList1"><li>Enter values in the Primary Key Class and Primary Key Field Name fields. The primary key uniquely identifies the entity bean.</li></div><a name="wp80790"> </a><div class="pSmartList1"><li>In the Abstract Schema Name field, enter a name that represents the entity bean. This name will be referenced in the EJB QL queries.</li></div></ol></div><a name="wp80794"> </a><p class="pBody">An example is shown in the section <a  href="CMP6.html#wp83102">Entity Tab (PlayerEJB)</a>.</p><a name="wp80796"> </a><h3 class="pHeading2">Defining EJB QL Queries for Finder and Select Methods</h3><a name="wp80797"> </a><p class="pBody">You specify these settings in the Finder/Select Methods dialog box.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp80798"> </a><div class="pSmartList1"><li>To open the Finder/Select Methods dialog box, go to the Entity tab and click Finder/Select Methods.</li></div><a name="wp80799"> </a><div class="pSmartList1"><li>To display a set of finder or select methods, click one of the radio buttons under the Show label.</li></div><a name="wp80800"> </a><div class="pSmartList1"><li>To specify an EJB QL query, choose the name of the finder or select method from the Method list and then enter the query in the field labeled EJB QL Query.</li></div></ol></div><a name="wp80803"> </a><p class="pBody">An example is shown in the section <a  href="CMP6.html#wp83132">Finder/Select Methods Dialog Box (PlayerEJB)</a>.</p><a name="wp80826"> </a><h3 class="pHeading2">Defining Relationships</h3><a name="wp80827"> </a><p class="pBody">The Relationships tab enables you to define relationships between entity beans that reside in the same EJB JAR file.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp80828"> </a><div class="pSmartList1"><li>Before you create a relationship between two entity beans, you must first create both beans with the New Enterprise Bean wizard.</li></div><a name="wp80829"> </a><div class="pSmartList1"><li>To display the Relationships tab, select the EJB JAR in the tree view and then select the Relationships tab. </li></div><a name="wp80830"> </a><div class="pSmartList1"><li>To add or edit a relationship, go the Relationships tab and click the appropriate button.</li></div><a name="wp80831"> </a><div class="pSmartList1"><li>The Add (or Edit) Relationship dialog box appears. (The Add Relationship and Edit Relationship dialog boxes are identical.)</li></div></ol></div><a name="wp80834"> </a><p class="pBody">An example is shown in the section <a  href="CMP6.html#wp83065">Edit Relationship Dialog Box (TeamJAR)</a>.</p><a name="wp78998"> </a><h3 class="pHeading2">Creating the Database Tables at Deploy Time in deploytool</h3><a name="wp82969"> </a><p class="pBody">The RosterApp example used a database schema file to map database tables to enterprise bean fields. You can alternately have the container create the database tables at deploy-time by setting some options in deploytool.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp82972"> </a><div class="pSmartList1"><li>Select TeamJAR in the tree in deploytool.</li></div><a name="wp82976"> </a><div class="pSmartList1"><li>Select the Relationships tabbed pane.</li></div><a name="wp82977"> </a><div class="pSmartList1"><li>Click Sun-specific Settings.</li></div><a name="wp82978"> </a><div class="pSmartList1"><li>Click Create Field Mappings.</li></div><a name="wp82979"> </a><div class="pSmartList1"><li>Select Automatically Generate Necessary Tables.</li></div><a name="wp82980"> </a><div class="pSmartList1"><li>Click OK.</li></div></ol></div><a name="wp82987"> </a><p class="pBody">When you deploy RosterApp, the tables will be created and named according to the values in the Persistent Field Mappings table.</p>    </blockquote>   <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="CMP7.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="MDB.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -