📄 ch06s04.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Telling JAWS about your tables</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="ch06.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06.html" title="Chapter 6. Customizing JAWS"><link rel="previous" href="ch06s03.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s03.html" title="JAWS Options"><link rel="next" href="ch06s07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s07.html" title="Declaring finders"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch06.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch06s03.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s03.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch06s07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s07.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table><div class="section"><a name="d0e2184"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e2184"></a>Telling JAWS about your tables</h2></div></div><p>JAWS will use one different table for each of your CMP entity beans. The table
for one entity bean will contain one column for each of the
CMP fields of this entity.</p><p>By default, JAWS will create the tables for you. The name of the table will be
the ejb-name of the bean, and the name of the columns will be
the names of the CMP fields. The jdbc type and the sql type will be the ones
given by the type-mapping. (see how the jdbc and sql type work
in <a href="ch06s13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s13.html" title="Defining a type mapping">the section called “Defining a type mapping”</a>)</p><p>However, you may want to override this behavior and tell JAWS which
names/types to use. For example, you may want JAWS to use an
already existing table. To do this, you must set these parameters in the <enterprise-beans> section of you jaws.xml file.
</p><div class="section"><a name="d0e2195"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2195"></a>Example 1</h3></div></div><p>You create an entity bean that will represent a class. You
already have the table in your database, it was created using the
following SQL statement:</p><p>CREATE TABLE CLASS (ID INTEGER, TEACHER VARCHAR(100), STUDENTNBR INTEGER);</p><p>This is how the your xml file will look like:</p><pre class="programlisting">
<jaws>
<enterprise-beans>
<entity>
<ejb-name>ClassBean</ejb-name>
<table-name>CLASS</table-name>
<create-table>false</create-table>
<cmp-field>
<field-name>classId</field-name>
<column-name>ID</column-name>
</cmp-field>
<cmp-field>
<field-name>teacherName</field-name>
<column-name>TEACHER</column-name>
</cmp-field>
<cmp-field>
<field-name>studentCount</field-name>
<column-name>STUDENTNBR</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jaws>
</pre></div><div class="section"><a name="d0e2206"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2206"></a>Example 2</h3></div></div><p>Your Class bean has a String field to hold the Teacher name.
You don't want to use the default mapping for a String
(VARCHAR(256)) since a name is not that long. Your xml file will
look like this:</p><pre class="programlisting">
<jaws>
<enterprise-beans>
<entity>
<ejb-name>ClassBean</ejb-name>
...
<cmp-field>
<field-name>teacherName</field-name>
<column-name>TEACHER</column-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(100)</sql-type>
</cmp-field>
...
</entity>
</enterprise-beans>
</jaws>
</pre><p>Note that the contents of the <ejb-name> tag and of all the
<field-name> tags must match the ones declared in
ejb-jar.xml.</p></div></div><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="432" height="79"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch06.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch06s03.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s03.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch06s07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch06s07.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -