<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd">
<mapping>
  <class name="ctf.jdo.tc2x.Master" access="shared" identity="id">
    <description>Test master table</description>
    <map-to table="tc2x_master" />
    <field name="id" type="integer">
      <sql name="id" type="numeric" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="group" type="ctf.jdo.tc2x.Group" required="false">
      <sql name="group_id"/>
    </field>
    <field name="details" type="ctf.jdo.tc2x.Detail" collection="arraylist" required="false">
      <sql many-key="master_id"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Detail" depends="ctf.jdo.tc2x.Master" access="shared" identity="id">
    <description>Test detail table</description>
    <map-to table="tc2x_detail" />
    <field name="id" type="integer">
      <sql name="detail_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="master" type="ctf.jdo.tc2x.Master" required="true">
      <sql name="master_id" />
    </field>
    <field name="details2" type="ctf.jdo.tc2x.Detail2" collection="arraylist" required="false">
      <sql many-key="detail_id"/>
    </field>
    <field name="detail3" type="ctf.jdo.tc2x.Detail3" required="false">
      <sql many-key="detail_id"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Detail2" depends="ctf.jdo.tc2x.Detail" access="shared" identity="id" key-generator="MAX">
    <description>Test detail2 table</description>
    <map-to table="tc2x_detail2" />
    <field name="id" type="integer">
      <sql name="detail2_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="detail" type="ctf.jdo.tc2x.Detail" required="true">
      <sql name="detail_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Detail3" depends="ctf.jdo.tc2x.Detail" access="shared" identity="id" >
    <description>Test detail3 table</description>
    <map-to table="tc2x_detail3" />
    <field name="id" type="integer">
      <sql name="detail3_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="detail" type="ctf.jdo.tc2x.Detail" required="true">
      <sql name="detail_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.MasterKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Test master table</description>
    <map-to table="tc2x_master" />
    <field name="id" type="integer">
      <sql name="id" type="numeric" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="group" type="ctf.jdo.tc2x.Group" required="false">
      <sql name="group_id"/>
    </field>
    <field name="details" type="ctf.jdo.tc2x.DetailKeyGen" collection="arraylist" required="false">
      <sql many-key="master_id"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.DetailKeyGen" depends="ctf.jdo.tc2x.MasterKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Test detail table</description>
    <map-to table="tc2x_detail" />
    <field name="id" type="integer">
      <sql name="detail_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="master" type="ctf.jdo.tc2x.MasterKeyGen" required="true">
      <sql name="master_id" />
    </field>
    <field name="details2" type="ctf.jdo.tc2x.DetailKeyGen2" collection="arraylist" required="false">
      <sql many-key="detail_id"/>
    </field>
    <field name="detail3" type="ctf.jdo.tc2x.DetailKeyGen3" required="false">
      <sql many-key="detail_id"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.DetailKeyGen2" depends="ctf.jdo.tc2x.DetailKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Test detail2 table</description>
    <map-to table="tc2x_detail2" />
    <field name="id" type="integer">
      <sql name="detail2_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="detail" type="ctf.jdo.tc2x.DetailKeyGen" required="true">
      <sql name="detail_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.DetailKeyGen3" depends="ctf.jdo.tc2x.DetailKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Test detail3 table</description>
    <map-to table="tc2x_detail3" />
    <field name="id" type="integer">
      <sql name="detail3_id" type="numeric" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="detail" type="ctf.jdo.tc2x.DetailKeyGen" required="true">
      <sql name="detail_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Group" access="shared" identity="id">
    <description>Test groups table</description>
    <map-to table="tc2x_group" />
    <field name="id" type="integer">
      <sql name="id" type="numeric" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.DependMaster" key-generator="MAX" identity="id">
    <map-to table="tc2x_depend_master" />
    <field name="id" type="integer">
      <sql name="id" />
    </field>
    <field name="depend1" type="ctf.jdo.tc2x.Depend1">
      <sql name="depend1_id" />
    </field>
    <field name="depends2" collection="arraylist" type="ctf.jdo.tc2x.Depend2">
      <sql many-key="master_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Depend1" key-generator="MAX" depends="ctf.jdo.tc2x.DependMaster" identity="id">
    <map-to table="tc2x_depend1" />
    <field name="id" type="integer">
      <sql name="id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.Depend2" key-generator="MAX" depends="ctf.jdo.tc2x.DependMaster" identity="id">
    <map-to table="tc2x_depend2" />
    <field name="id" type="integer">
      <sql name="id" />
    </field>
    <field name="master" type="ctf.jdo.tc2x.DependMaster">
      <sql name="master_id" />
    </field>
  </class>

  <class name="ctf.jdo.tc2x.MaxObject" identity="id" key-generator="MAX">
    <description>Table used for MAX key generator testing</description>
    <map-to table="tc2x_keygen" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.MaxExtends" extends="ctf.jdo.tc2x.MaxObject">
    <description>Table used for MAX key generator testing</description>
    <map-to table="tc2x_keygen_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.HighLowObject" identity="id" key-generator="HIGH-LOW">
    <description>Table used for HIGH-LOW key generator testing</description>
    <map-to table="tc2x_keygen" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.HighLowExtends" extends="ctf.jdo.tc2x.HighLowObject">
    <description>Table used for HIGH-LOW key generator testing</description>
    <map-to table="tc2x_keygen_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.HighLowObjectSameConnection" identity="id" key-generator="HLSC">
    <description>Table used for HIGH-LOW key generator testing with same-connection=true</description>
    <map-to table="tc2x_keygen" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.HighLowExtendsSameConnection" extends="ctf.jdo.tc2x.HighLowObjectSameConnection">
    <description>Table used for HIGH-LOW key generator testing with same-connection=true</description>
    <map-to table="tc2x_keygen_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.SequenceObject" identity="id" key-generator="SEQUENCE">
    <description>Table used for SEQUENCE key generator testing</description>
    <map-to table="tc2x_keygen" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.SequenceExtends" extends="ctf.jdo.tc2x.SequenceObject">
    <description>Table used for SEQUENCE key generator testing</description>
    <map-to table="tc2x_keygen_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.IdentityObject" identity="id" key-generator="IDENTITY">
    <description>Table used for IDENTITY key generator testing</description>
    <map-to table="tc2x_identity" />
    <field name="id" type="integer">
      <sql name="id" type="numeric" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.IdentityExtends" extends="ctf.jdo.tc2x.IdentityObject">
    <description>Table used for IDENTITY key generator testing</description>
    <map-to table="tc2x_identity_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.ReturningObject" identity="id" key-generator="RETURNING">
    <description>Table used for SEQUENCE key generator testing in RETURNING mode for Oracle8i</description>
    <map-to table="tc2x_keygen" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.ReturningExtends" extends="ctf.jdo.tc2x.ReturningObject">
    <description>Table used for SEQUENCE key generator testing in RETURNING mode for Oracle8i</description>
    <map-to table="tc2x_keygen_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.UuidObject" identity="id" key-generator="UUID">
    <description>Table used for UUID key generator testing</description>
    <map-to table="tc2x_uuid" />
    <field name="id" type="string">
      <sql name="id" type="char" />
    </field>
    <field name="attr" type="string" required="true">
      <sql name="attr" type="varchar"/>
    </field>
  </class>

  <class name="ctf.jdo.tc2x.UuidExtends" extends="ctf.jdo.tc2x.UuidObject">
    <description>Table used for UUID key generator testing</description>
    <map-to table="tc2x_uuid_ext" />
    <field name="ext" type="string" required="true">
      <sql name="ext" type="varchar"/>
    </field>
  </class>

  <key-generator name="HIGH-LOW">
    <param name="table" value="tc2x_seqtable"/>
    <param name="key-column" value="table_name"/>
    <param name="value-column" value="max_id"/>
    <param name="grab-size" value="1000"/>
  </key-generator>
  
  <key-generator name="HIGH-LOW" alias="HLSC">
    <param name="table" value="tc2x_seqtable"/>
    <param name="key-column" value="table_name"/>
    <param name="value-column" value="max_id"/>
    <param name="grab-size" value="1000"/>
    <param name="same-connection" value="true"/>
  </key-generator>

  <key-generator name="SEQUENCE" alias="RETURNING">
    <param name="returning" value="true"/>
  </key-generator>
</mapping>
