mpoeschl 01/07/15 16:52:27
Modified: xdocs/howto torque-howto.xml
xdocs/stylesheets project.xml
Added: xdocs/howto torque-schema-ref.xml
Log:
"Warner Onstine" <[EMAIL PROTECTED]>:
Hi all,
I have written a rough version of a torque-schema doc, which hopefully will
help to explain to new-comers what they need to do to set up their own
schemas.
Revision Changes Path
1.8 +26 -8 jakarta-turbine/xdocs/howto/torque-howto.xml
Index: torque-howto.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine/xdocs/howto/torque-howto.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- torque-howto.xml 2001/06/07 00:12:47 1.7
+++ torque-howto.xml 2001/07/15 23:52:27 1.8
@@ -216,18 +216,36 @@
</table>
- <table name="Jobentry">
- <column name="JOBID" null="false" primaryKey="true" type="INTEGER"/>
- <column name="MINUTE" default="-1" null="false" type="INTEGER"/>
- <column name="HOUR" default="-1" null="false" type="INTEGER"/>
- <column name="WEEKDAY" default="-1" null="false" type="INTEGER"/>
- <column name="DAY_OF_MONTH" default="-1" null="false" type="INTEGER"/>
- <column name="TASK" null="false" size="99" type="VARCHAR"/>
- <column name="EMAIL" size="99" type="VARCHAR"/>
+ <table name="TURBINE_PERMISSION" idMethod="idbroker">
+ <column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER"/>
+ <column name="PERMISSION_NAME" required="true" size="99" type="VARCHAR"
javaName="Name"/>
+
+ <unique>
+ <unique-column name="PERMISSION_NAME"/>
+ </unique>
+
</table>
+ <table name="TURBINE_ROLE_PERMISSION">
+ <column name="ROLE_ID" required="true" primaryKey="true" type="INTEGER"/>
+ <column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER"/>
+
+ <foreign-key foreignTable="TURBINE_ROLE">
+ <reference local="ROLE_ID" foreign="ROLE_ID"/>
+ </foreign-key>
+
+ <foreign-key foreignTable="TURBINE_PERMISSION">
+ <reference local="PERMISSION_ID" foreign="PERMISSION_ID"/>
+ </foreign-key>
+ </table>
+
</database>
]]></source>
+
+<p>
+Please refer to <a href="torque-schema-ref.html">Torque Schema Reference</a>
+to find out more about the the different elements and attributes.
+</p>
<!--
1.1 jakarta-turbine/xdocs/howto/torque-schema-ref.xml
Index: torque-schema-ref.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>Torque Database Schema Reference</title>
<author email="[EMAIL PROTECTED]">Jon S. Stevens</author>
<author email="[EMAIL PROTECTED]">Warner Onstine</author>
</properties>
<body>
<section name="Torque Database Schema Reference">
<p>
The Torque Database Schema Reference attempts to explain what the different elements
and attributes are when defining your own database schema. In addition I will
attempt to
explain what attributes mean what in the different databases currently supported.
</p>
</section>
<section name="Elements and their attributes">
<p>
Some of the following examples are taken from the project-schema.xml document in the
src/conf/torque/schema.
</p>
<subsection name="Element: database">
<p>The database element and its relevant attributes.</p>
<source><![CDATA[
<database name="MY_DATABASE"
defaultIdMethod="idBroker"
package="com.myapp.om"
baseClass="com.myapp.om.BaseClass"
basePeer="com.myapp.om.BasePeer">
<table name="SIMPLE">
<!-- table info goes here -->
</table>
</database>]]>
</source>
<p>
The database element has 5 attributes associated with it, they are:
<ul>
<li>name - The name of the database being referenced</li>
<li>defaultIdMethod - How will the primary keys be created, defaults to
"none"</li>
<li>package - used for OM Peer generation</li>
<li>baseClass - used for OM generation</li>
<li>basePeer - used for OM Peer generation</li>
</ul>
The last four will be explained in detail below.
</p>
<p>
The database element can contain the following elements:
<ul>
<li>table - one or more</li>
</ul>
</p>
</subsection>
<subsection name="Attribute: defaultIdMethod">
<p>
By defining this attribute at the database level it applies the defaultIdMethod
to those
tables which do not have an idMethod attribute defined.
The attribute defaultIdMethod has 5 possible values, they are:
<ul>
<li>idbroker - This allows turbine to generate the IDs through its
IDBroker Service</li>
<li>native - Turbine will determine how the database will auto-generate
IDs</li>
<li>autoincrement - deprecated, please use native</li>
<li>sequence - deprecated, please use native</li>
<li>none - Typically used if you do not want IDs generated</li>
</ul>
</p>
</subsection>
<subsection name="Attribute: package">
<p>
The base package in which this database will generate the Object Models
associated with it.
This overrides the targetPackage property in the torque build.properties file.
</p>
</subsection>
<subsection name="Attribute: baseClass">
<p>
The base class to use when generating the Object Model.
This class does not have to extend org.apache.turbine.om.BaseObject.
</p>
</subsection>
<subsection name="Attribute: basePeer">
<p>
The base peer to use when generating the Object Model Peers.
Unlike baseClass, basePeer should extend BasePeer at some point in the chain, ie
- it needs to be the superclass.
</p>
</subsection>
<subsection name="Element: table">
<p>The table element and its relevant attributes</p>
<source><![CDATA[
<table name="MY_TABLE"
javaName="table"
idMethod="idbroker"
skipSql="false"
baseClass="com.myapp.om.table.BaseClass"
basePeer="com.myapp.om.table.BasePeer">
<!-- column information here -->
</table>]]>
</source>
<p>
The table element has 8 attributes associated with it, they are:
<ul>
<li>name - The name of the database being referenced</li>
<li>javaName - How this table will be referenced in java</li>
<li>idMethod - How will the primary keys be created, defaults to
"none"</li>
<li>skipSql - Whether or not to skip SQL generation for this
reference</li>
<li>abstract - Whether or not to generate the class as Abstract or
not</li>
<li>alias - The table alias</li>
<li>baseClass - used for OM Peer generation</li>
<li>basePeer - used for OM Peer generation</li>
</ul>
</p>
<p>
The table element can contain the following elements:
<ul>
<li>column - one or more</li>
<li>foreign-key - 0 or more</li>
<li>index - 0 or more</li>
<li>unique - 0 or more</li>
<li>id-method-parameter - 0 or more</li>
</ul>
</p>
</subsection>
<subsection name="Attribute: javaName">
<p>
This is the java class name to use when generating the Table or column. If this
is missing the java name is generated
in the following manner:<br/>
Underscores are removed, first letter and first letter after each underscore is
uppercased,
all other letters are lowercased. So YOUR_TABLE_NAME would become YourTableName.
</p>
</subsection>
<subsection name="Element: column">
<p>The column element and its relevant attributes</p>
<source><![CDATA[
<column name="MY_COLUMN"
javaName="Column"
primaryKey="true"
required="true"
size="4"
type="VARCHAR">
<!-- inheritance info if necessary -->
</column>
]]>
</source>
<p>
The column element has 8 attributes associated with it, they are:
<ul>
<li>name - The name of the column being referenced</li>
<li>javaName - How this column will be referred to in Java</li>
<li>primaryKey - Is this a primary key or not (true or false)</li>
<li>required - Whether a value is required in this field (true or
false)</li>
<li>type - What type of column is it? (Covered below), defaults to
VARCHAR</li>
<li>size - How many characters or digits can be stored?</li>
<li>default - Default value to insert into field if it is missing.</li>
<li>autoIncrement - Whether or not to auto-increment this field,
defaults to "false"</li>
<li>inheritance - ?</li>
<li>inputValidator - ?</li>
</ul>
</p>
<p>
The column element can contain the following elements:
<ul>
<li>inheritance - 0 or more</li>
</ul>
</p>
</subsection>
<subsection name="Element: inheritance">
<p>The inheritance element and its relevant attributes</p>
<source><![CDATA[
<inheritance key="key"
class="classname"
extends="mybase"/>
]]>
</source>
<p>
The inheritance element has 3 attributes associated with it, they are:
<ul>
<li>key - ?</li>
<li>class - ?</li>
<li>extends - ?</li>
</ul>
</p>
</subsection>
<subsection name="Element: foreign-key">
<p>The foreign-key element and its relevant attributes</p>
<source><![CDATA[
<foreign-key foreignTable="MY_TABLE">
<!-- reference info -->
</foreign-key>
]]>
</source>
<p>
The foreign-key element has 1 attribute associated with it, it is:
<ul>
<li>foreignTable - the name of the table being referenced</li>
</ul>
</p>
<p>
The foreign-key element can contain the following elements:
<ul>
<li>reference - 1 or more</li>
</ul>
</p>
</subsection>
<subsection name="Element: reference">
<p>The reference element and its relevant attributes</p>
<source><![CDATA[
<reference local="FK_TABLE_ID" foreign="PK_COLUMN_ID"/>
]]>
</source>
<p>
The reference element has 2 attributes associated with it, they are:
<ul>
<li>local - the local reference</li>
<li>foreign - the foreign key reference</li>
</ul>
</p>
</subsection>
</section>
</body>
</document>
1.34 +1 -0 jakarta-turbine/xdocs/stylesheets/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine/xdocs/stylesheets/project.xml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- project.xml 2001/07/09 20:51:31 1.33
+++ project.xml 2001/07/15 23:52:27 1.34
@@ -48,6 +48,7 @@
<item name="Sybase Howto" href="/howto/sybase-howto.html"/>
<item name="TDK Howto" href="/howto/tdk-howto.html"/>
<item name="Torque Howto" href="/howto/torque-howto.html"/>
+ <item name="Torque Schema Ref" href="/howto/torque-schema-ref.html"/>
<item name="Velocity Site Howto" href="/howto/velocity-site-howto.html"/>
<item name="Velocity Context Howto" href="/howto/context-howto.html"/>
<item name="Webmacro Site Howto" href="/howto/webmacro-site-howto.html"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]