Torque Database Schema ReferenceTorque was developed as part of the Turbine Framework (version 2.1). It is now decoupled and can be used by itself. Starting with Turbine 2.2 the coupled version of Torque is deprecated. You should upgrade to use the decoupled version. 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. Elements and their attributesSome of the following examples are taken from the project-schema.xml document in the src/conf/torque/schema. Element: databaseThe database element and its relevant attributes. <database name="MY_DATABASE" defaultIdMethod="idbroker" package="com.myapp.om" baseClass="com.myapp.om.BaseClass" basePeer="com.myapp.om.BasePeer" defaultJavaNamingMethod="underscore"> <table name="SIMPLE"> <!-- table info goes here --> </table> </database> The database element has 6 attributes associated with it, they are:
The database element can contain the following elements:
Attribute: defaultIdMethodBy 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:
Attribute: defaultJavaNamingMethodThis attribute determines how table or column names, from the name attribute of the table or column element, are converted to a Java class or method name respectively when creating the OM java objects. defaultJavaNamingMethod can contain 3 different values:
Attribute: packageThe 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. Attribute: baseClassThe base class to use when generating the Object Model. This class does not have to extend org.apache.turbine.om.BaseObject. Attribute: basePeerThe 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. Element: tableThe table element and its relevant attributes <table name="MY_TABLE" javaName="table" idMethod="idbroker" skipSql="false" baseClass="com.myapp.om.table.BaseClass" basePeer="com.myapp.om.table.BasePeer" javaNamingMethod="underscore"> <!-- column information here --> </table> The table element has 9 attributes associated with it, they are:
The table element can contain the following elements:
Attribute: javaName
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: Element: columnThe column element and its relevant attributes <column name="MY_COLUMN" javaName="Column" primaryKey="true" required="true" size="4" type="VARCHAR" javaNamingMethod="underscore"> <!-- inheritance info if necessary --> </column> The column element has 9 attributes associated with it, they are:
The column element can contain the following elements:
Element: inheritanceThe inheritance element and its relevant attributes <inheritance key="key" class="classname" extends="mybase"/> The inheritance element has 3 attributes associated with it, they are:
Element: foreign-keyThe foreign-key element and its relevant attributes <foreign-key foreignTable="MY_TABLE"> <!-- reference info --> </foreign-key> The foreign-key element has 1 attribute associated with it, it is:
The foreign-key element can contain the following elements:
Element: referenceThe reference element and its relevant attributes <reference local="FK_TABLE_ID" foreign="PK_COLUMN_ID"/> The reference element has 2 attributes associated with it, they are:
|