Torque Schema Reference

Torque スキーマリファレンス

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.

このTorqueデータベーススキーマリファレンスは、 データベーススキーマを定義する際の様々な要素や属性について、 詳細に説明することを試みます。 さらに、様々なデータベースでの現在の属性のサポートについても説明します。

Elements and their attributes

要素と属性

Some of the following examples are taken from the project-schema.xml document in the src/conf/torque/schema.

以下の例のうちのいくつかは src/conf/torque/schema の中の project-schema.xmlドキュメントから取得できます。

Element: database

要素: database

The database element and its relevant attributes.

これはdatabase要素と関連する属性です。

         <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>
       

The database element has 8 attributes associated with it, they are:

database要素は8つの属性を持ちます。それらは:

name The name of the database being referenced
defaultIdMethod How will the primary keys be created, defaults to "none"
defaultJavaType Default type of columns in the database (object or primitive, defaults to primitive)
package Used for OM Peer generation
baseClass Used for OM generation
basePeer Used for OM Peer generation
defaultJavaNamingMethod Indicates how a schema table or column name is mapped to a Java class or method name respectively
heavyIndexing ? (true or false, defaults to false)

name 参照するときのデータベースの名称
defaultIdMethod プライマリーキーをどのように作成するか。デフォルトは"none"
defaultJavaType データベースの列のデフォルトの型 (object または primitive, デフォルトは primitive)
package OM Peer 生成に使用される
baseClass OM 生成に使用される
basePeer OM Peer 生成に使用される
defaultJavaNamingMethod Java クラス・メソッド名それぞれに、 スキーマのテーブル・列名がどのようにマッピングされるかを指定する
heavyIndexing ? (true または false, デフォルトは false)

The database element can contain the following elements:

database 要素は以下の要素を内包できます:

table 1 or more

Attribute: defaultIdMethod

属性: defaultIdMethod

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:

database要素にこの属性を定義することにより、 idMethod属性を定義していないテーブルにdefaultIdMethodを適用します。 属性defaultIdMethodは5つの有効な値を持っています。 それらは:

idbroker This allows turbine to generate the IDs through its IDBroker Service
native Turbine will determine how the database will auto-generate IDs
autoincrement deprecated, please use native
sequence deprecated, please use native
none Typically used if you do not want IDs generated

idbroker turbineがIDBroker Serviceを通してIDを生成
native どのようにデータベースがIDを自動生成するかをTurbineが決定する
autoincrement 推奨されません、nativeを使用してください
sequence 推奨されません、nativeを使用してください
none IDを生成したくないときに使用します

Attribute: defaultJavaNamingMethod

属性: defaultJavaNamingMethod

This 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:

この属性は、OM Javaオブジェクトを作成するときに、 テーブル名または列名(table要素またはcolumn要素のname属性)を、 Javaクラス名またはメソッド名にどのようにそれぞれ変換するかを決定します。 defaultJavaNamingMethodは3つの異なる値を含むことができます:

nochange Indicates no change is performed.
underscore Underscores are removed, First letter is capitalized, first letter after an underscore is capitalized, the rest of the letters are converted to lowercase.
javaname Same as underscore, but no letters are converted to lowercase.

nochange なんの変換も行われない
underscore アンダースコアは削除、一文字目が大文字、 アンダースコアの後ろの一文字は大文字、残りの文字は小文字に変換される
javaname underscoreと同じであるが、小文字への変換は行われない

Attribute: package

属性: package

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.

データベースがオブジェクトモデルを生成したときのベースパッケージとなります。 これは、Torqueのbuild.propertiesファイル中のtargetPackageプロパティをオーバライドします。

Attribute: baseClass

属性: baseClass

The base class to use when generating the Object Model. This class does not have to extend org.apache.turbine.om.BaseObject.

オブジェクトモデルを生成する際に使用するベースクラスです。 このクラスはorg.apache.turbine.om.BaseObjectを継承する必要はありません。

Attribute: basePeer

属性: basePeer

The base peer to use when generating the Object Model Peers. Unlike baseClass, basePeer should extend BasePeer at some point in the chain, i.e it needs to be the superclass.

オブジェクトモデルのPeerを生成する際に使用されます。 baseClassと異なり、basePeerは継承階層のいずれかでBasePeerを継承するべきです。言い換えれば、スーパークラスであることが必要です。

Element: table

要素: table

The table element and its relevant attributes

これはtable要素と関連する属性です。

         <table
           name="MY_TABLE"
           javaName="table"
           idMethod="idbroker"
           skipSql="false"
           baseClass="com.myapp.om.table.BaseClass"
           basePeer="com.myapp.om.table.BasePeer"
           javaNamingMethod="underscore"
           description="Table for Torque tests">

           <!-- column information here -->

         </table>
       

The table element has 13 attributes associated with it, they are:

table要素は13の属性を持ちます。それらは:

name The name of the table being referenced
javaName How this table will be referenced in Java
idMethod How will the primary keys be created, defaults to "null"
skipSql Whether or not to skip SQL generation for this reference
abstract Whether or not to generate the class as Abstract or not
baseClass Used for OM Peer generation
basePeer Used for OM Peer generation
alias The table alias
interface ?
javaNamingMethod Specifies how the name attribute is converted to the Java class name of the corresponding OM object. This attribute overrides the defaultJavaNamingMethod attribute of the database element
heavyIndexing ? (true or false)
description Used for doc generation

name 参照のするときのテーブルの名称
javaName Java上で参照するときのテーブルの名称
idMethod プライマリーキーをどのように作成するか。デフォルトは"null"
skipSql SQLの生成をスキップするかどうか
abstract 抽象クラスとして生成するかどうか
baseClass OM Peer 生成に使用される
basePeer OM 生成に使用される
alias テーブルの別名
interface ?
javaNamingMethod 属性が対応するOMオブジェクトのJavaクラス名にどのように変換されるかを定義する。 この属性は、database要素のdefaultJavaNamingMethod属性をオーバライドする。
heavyIndexing ? (true または false)
description ドキュメント生成時に使用される

The table element can contain the following elements:

table要素は以下の要素を内包できます:

column 1 or more
foreign-key 0 or more
index 0 or more
unique 0 or more
id-method-parameter 0 or more

Attribute: javaName

属性: 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:

これはテーブルまたはカラムを生成する場合に使用するJavaクラス名です。 これが見当たらない場合、Java名は次の方法で生成されます:

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.

アンダースコアは削除され、一番最初の一文字、 および各アンダーラインの後の一文字は大文字となります。 他のすべての文字は小文字となります。 したがって、YOUR_TABLE_NAMEはYourTableNameになります。

Element: column

要素: column

The column element and its relevant attributes

これはcolumn要素と関連する属性です。

         <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 13 attributes associated with it, they are:

column要素は13の属性を持ちます。それらは:

name The name of the column being referenced
javaName How this column will be referred to in Java
primaryKey Is this a primary key or not (true or false, defaults to false)
required Whether a value is required in this field (true or false, defaults to false)
type What type of column is it? Covered below, defaults to VARCHAR
javaType The type of the column in Java (object or primitive)
size How many characters or digits can be stored?
default Default value to insert into field if it is missing.
autoIncrement Whether or not to auto-increment this field (true or false, defaults to false)
inheritance ? (single or false, defaults to false)
inputValidator ?
javaNamingMethod Specifies how the name attribute is converted to the Java class name of the corresponding OM object. This attribute overrides the defaultJavaNamingMethod attribute of the database element
description Used for doc generation

name 参照するときのカラムの名称
javaName Java上で参照するときのカラムの名称
primaryKey プライマリーキーであるかどうか (true または false, デフォルトは false)
required 値が必須であるかどうか (true または false, デフォルトは false)
type カラムの型がなんであるか。 Covered below, デフォルトは VARCHAR
javaType Java上でのこのカラムの型 (object または primitive)
size どれだけの文字または数字を格納できるか。
default インサート時に値が指定されていない場合のデフォルト値
autoIncrement 自動インクリメントするかどうか (true または false, デフォルトは false)
inheritance ? (single または false, デフォルトは false)
inputValidator ?
javaNamingMethod 属性が対応するOMオブジェクトのJavaクラス名にどのように変換されるかを定義する。 この属性は、database要素のdefaultJavaNamingMethod属性をオーバライドする。
description ドキュメント生成時に使用する

The column element can contain the following elements:

column要素は以下の要素を内包できます:

inheritance 0 or more

Element: inheritance

要素: inheritance

The inheritance element and its relevant attributes

これはinheritance要素と関連する属性です。

          <inheritance key="key"
            class="classname"
            extends="mybase"/>
        

The inheritance element has 3 attributes associated with it, they are:

inheritance要素は3つの属性を持ちます。それらは:

key ?
class ?
extends ?

key ?
class ?
extends ?

The inheritance element can not contain other elements.

inheritance要素は他の要素を含むことはできません。

Element: foreign-key

要素: foreign-key

The foreign-key element and its relevant attributes

これはforein-key要素と関連する属性です。

        <foreign-key foreignTable="MY_TABLE"
          name="MY_TABLE_FK"
          onUpdate="none"
          onDelete="none">
          <!-- reference info -->
        </foreign-key>
      

The foreign-key element has 4 attributes associated with it, they are:

foreign-key要素は4つの属性を持ちます。それらは:

foreignTable The name of the table being referenced
name The name of the foreign key
onUpdate The action to take when the referenced value in foreignTable is updated
onDelete The action to take when the referenced value in foreignTable is deleted

foreignTable 参照するときのテーブルの名称
name 外部キーの名称
onUpdate 外部テーブルの参照している値が更新されたときに実行するアクション
onDelete 外部テーブルの参照している値が削除されたときに実行するアクション

The foreign-key element can contain the following elements:

foreign-key 要素は以下の要素を内包できます:

reference 1 or more

Element: reference

要素: reference

The reference element and its relevant attributes

これはreference要素と関連する属性です。

        <reference local="FK_TABLE_ID" foreign="PK_COLUMN_ID"/>
      

The reference element has 2 attributes associated with it, they are:

reference要素は2つの属性を持ちます。それらは:

local The local reference
foreign The foreign key reference

local ローカルの参照先
foreign 外部キーの参照先

The reference element can not contain other elements.

reference要素は他の要素を含むことはできません。

Element: index

要素: index

The index element and its relevant attributes

これはindex要素と関連する属性です。

        <index name="MY_INDEX">
          <!-- index-column info -->
        </index>
      

The index element has 1 attribute associated with it, it is:

index要素は1つの属性を持ちます。それらは:

name The name of the index

name インデックスの名称

The index element can contain the following elements:

index要素は以下の要素を内包できます:

index-column 1 or more

Element: index-column

要素: index-column

The index-column element and its relevant attributes

これはindex-column要素と関連する属性です。

        <index-column name="INDEX_COLUMN"/>
      

The index-column element has 2 attributes associated with it, they are:

index-column要素は2つの属性を持ちます。それらは:

name The name of the indexed column
size ?

name インデックスを付与するカラムの名称
size ?

The index-column element can not contain other elements.

index-column要素は他の要素を含むことはできません。

Element: unique

The unique element and its relevant attributes

これはunique要素と関連する属性です。

        <unique name="MY_UNIQUE">
          <!-- unique-column info -->
        </unique>
      

The unique element has 1 attribute associated with it, it is:

unique要素は1つの属性を持ちます。それらは:

name The name of the unique constraint

name ユニーク制約の名称

The unique element can contain the following elements:

unique要素は以下の要素を内包できます:

unique-column 1 or more

要素: unique-column

The unique-column element and its relevant attributes

これはunique-column要素と関連する属性です。

        <index-column name="UNIQUE_COLUMN"/>
      

The unique-column element has 1 attribute associated with it, it is:

unique-column要素は1つの属性を持ちます。それらは:

name The name of the unique column

name ユニークとなるカラムの名称

The unique-column element can not contain other elements.

unique-column要素は他の要素を含むことはできません。