<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd">
<mapping>
  <include href="../ctf/jdo/tc0x/mapping.xml"/>
  <include href="../ctf/jdo/tc1x/mapping.xml"/>
  <include href="../ctf/jdo/tc2x/mapping.xml"/>
  <include href="../ctf/jdo/tc9x/mapping.xml"/>
  <include href="tc166/mapping.xml"/>
  <include href="tc167/mapping.xml"/>
  

  <!-- Mapping for TestObject to test_table
       Single object mapping, shared access, dirty checking on all fields -->

  <class name="jdo.TestManyGroup" access="shared" identity="id" >
    <description>Table used for testing many to many relation</description>
    <map-to table="test_many_group" />
    <field name="id" type="integer">
      <sql name="gid" type="integer" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="people" type="jdo.TestManyPerson" collection="collection"
    required="false" set-method="setPeople" get-method="getPeople">
    <sql many-table="test_group_person"/>
    </field>
  </class>

  <class name="jdo.TestManyPerson" access="shared" identity="id" >
    <description>Table used for testing many to many relation</description>
    <map-to table="test_many_person" />
    <field name="id" type="integer">
      <sql name="pid" type="integer" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="helloworld" type="string" >
      <sql name="helloworld" type="varchar" />
    </field>
    <field name="sthelse" type="string"  >
      <sql name="sthelse" type="varchar" />
    </field>
    <field name="group" type="jdo.TestManyGroup" collection="collection"
    required="false">
      <sql many-table="test_group_person"/>
    </field>
  </class>

  <class name="jdo.TestManyGroupKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Table used for testing many to many relation</description>
    <cache-type type="count-limited" capacity="30"/>
    <map-to table="test_many_group" />
    <field name="id" type="integer">
      <sql name="gid" type="integer" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="people" type="jdo.TestManyPersonKeyGen" collection="collection"
    required="false" >
    <sql many-table="test_group_person"/>
    </field>
  </class>

  <class name="jdo.TestManyPersonKeyGen" access="shared" identity="id" key-generator="MAX">
    <description>Table used for testing many to many relation</description>
    <cache-type type="count-limited" capacity="30"/>
    <map-to table="test_many_person" />
    <field name="id" type="integer">
      <sql name="pid" type="integer" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="helloworld" type="string" >
      <sql name="helloworld" type="varchar" />
    </field>
    <field name="sthelse" type="string"  >
      <sql name="sthelse" type="varchar" />
    </field>
    <field name="group" type="jdo.TestManyGroupKeyGen" collection="collection"
    required="false">
      <sql many-table="test_group_person"/>
    </field>
  </class>

  <!-- Test lazy loading -->
  <class name="jdo.TestLazyPerson" identity="firstName lastName">
    <description>Table used for testing lazy loading</description>
    <map-to table="test_pks_person" />
    <field name="firstName" type="string"  required="true">
      <sql name="fname" type="varchar" />
    </field>
    <field name="lastName" type="string" required="true">
      <sql name="lname" type="varchar" />
    </field>
    <field name="birthday" type="date"  >
      <sql name="bday" type="date" />
    </field>
    <field name="address" type="jdo.TestLazyAddress" collection="collection" lazy="true" 
           set-method="setAddress" get-method="getAddress"/>
  </class>

  <class name="jdo.TestLazyAddress" depends="jdo.TestLazyPerson" identity="id">
    <description>Table used for testing lazy loading</description>
    <map-to table="test_pks_address" />
    <field name="id" type="integer" >
      <sql name="id" type="integer" />
    </field>
    <field name="street" type="string" >
      <sql name="street" type="varchar"/>
    </field>
    <field name="city" type="string" >
      <sql name="city" type="varchar" />
    </field>
    <field name="state" type="string" >
      <sql name="state" type="varchar" />
    </field>
    <field name="zip" type="string" >
      <sql name="zip" type="varchar" />
    </field>
    <field name="Person" type="jdo.TestLazyPerson">
      <sql name="fname lname"/>
    </field>
  </class>

  <class name="jdo.TestLazyEmployee" extends="jdo.TestLazyPerson">
    <description>Table used for testing lazy loading for extends</description>
    <map-to table="test_pks_employee" />
    <field name="startDate" type="date" >
      <sql name="start_date" type="date" />
    </field>
    <field name="payRoll" type="jdo.TestLazyPayRoll" />
    <field name="contract" type="jdo.TestLazyContract" />
    <field name="projects" type="jdo.TestLazyProject" collection="collection" lazy="true"/>
  </class>

  <class name="jdo.TestLazyProject" identity="id">
    <description>Table used for testing lazy loading</description>
    <map-to table="test_pks_project" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="owner" type="jdo.TestLazyEmployee">
      <sql name="fname lname"/>
    </field>
    <field name="name" type="string">
      <sql name="name" type="varchar"/>
    </field>
  </class>

  <class name="jdo.TestLazyContract" depends="jdo.TestLazyEmployee" identity="policyNo contractNo">
    <description>Table used for testing multiple primary keys for extends</description>
    <map-to table="test_pks_contract" />
    <field name="policyNo" type="integer" >
      <sql name="policy_no" type="integer"/>
    </field>
    <field name="contractNo" type="integer">
      <sql name="contract_no" type="integer"/>
    </field>
    <field name="comment" type="string">
      <sql name="c_comment" type="varchar"/>
    </field>
    <field name="category" type="jdo.TestLazyContractCategory" collection="collection" >
      <sql many-table="test_pks_category_contract" many-key="policy_no contract_no" name="cate_id" />
    </field>
    <field name="employee" type="jdo.TestLazyEmployee" >
      <sql name="fname lname" />
    </field>
  </class>

  <class name="jdo.TestLazyContractCategory" identity="id" >
    <map-to table="test_pks_category" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="name" type="string">
      <sql name="name" type="varchar" />
    </field>
    <field name="contract" type="jdo.TestLazyContract" collection="collection" >
      <sql many-table="test_pks_category_contract" many-key="cate_id" name="policy_no contract_no" />
    </field>
  </class>

  <class name="jdo.TestLazyPayRoll" depends="jdo.TestLazyEmployee" identity="id">
    <description>Table used for testing lazy loading</description>
    <map-to table="test_pks_payroll" />
    <field name="id" type="integer">
      <sql name="id" type="integer"/>
    </field>
    <field name="holiday" type="integer" >
      <sql name="holiday" type="integer" />
    </field>
    <field name="hourlyRate" type="integer" >
      <sql name="hourly_rate" type="integer" />
    </field>
    <field name="employee" type="jdo.TestLazyEmployee" >
      <sql name="fname lname" />
    </field>
  </class>


  <!-- Test Multiple primary Keys -->
  <class name="jdo.TestLimit" access="shared" identity="id">
    <description>Table used for concurrency and performance testing</description>
    <map-to table="test_table" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar"/>
    </field>
    <field name="value2" type="string">
      <sql name="value2" type="varchar" dirty="ignore"/>
    </field>
  </class>
  
  <class name="jdo.TestObject" access="shared" identity="id">
    <description>Table used for concurrency and performance testing</description>
    <map-to table="test_table" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar"/>
    </field>
    <field name="value2" type="string">
      <sql name="value2" type="varchar" dirty="ignore"/>
    </field>
  </class>
  
  <class name="jdo.TestObjectExtends" access="shared" extends="jdo.TestObject">
    <description>Table used for cache testing</description>
    <map-to table="test_table_extends" />
    <field name="value3" type="string">
      <sql name="value3" type="varchar"/>
    </field>
    <field name="value4" type="string">
      <sql name="value4" type="varchar" dirty="ignore"/>
    </field>
  </class>

  <class name="jdo.TestObjectEx" access="shared" identity="id">
    <description>Table used for cache testing</description>
    <map-to table="test_table_ex" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <field name="value1" type="string" required="true">
      <sql name="value1" type="varchar"/>
    </field>
    <field name="value2" type="string">
      <sql name="value2" type="varchar" dirty="ignore"/>
    </field>
  </class>

  <class name="jdo.TestGroup" access="shared" identity="id">
    <description>Test groups table</description>
    <map-to table="test_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="jdo.TestPersistent" access="shared" identity="id">
    <description>Test Persistent interface handling</description>
    <map-to table="test_persistent" />
    <field name="id" type="integer">
      <sql name="id" type="integer"/>
    </field>
    <field name="creationTime" type="java.util.Date" required="true">
      <sql name="ctime" type="timestamp" />
    </field>
    <field name="modificationTime" type="java.util.Date" required="false">
      <sql name="mtime" type="timestamp" dirty="ignore" />
    </field>
    <field name="value1" type="string"  required="true">
      <sql name="value1" type="varchar" />
    </field>
    <field name="parentId" type="integer" required="false">
      <sql name="parent_id" type="integer" dirty="ignore" />
    </field>
    <field name="group" type="jdo.TestGroup" required="true">
      <sql name="group_id" />
    </field>
    <field name="related" type="jdo.TestPersistRelated" required="false">
      <sql many-key="persist_id" />
    </field>
  </class>

  <class name="jdo.TestPersistRelated" access="shared" identity="id" key-generator="MAX">
    <description>Test Persistent interface handling</description>
    <map-to table="test_related" />
    <field name="id" type="integer">
      <sql name="id" type="integer"/>
    </field>
    <field name="persistent" type="jdo.TestPersistent">
      <sql name="persist_id" />
    </field>
  </class>

  <class name="jdo.TestOqlExtends" extends="jdo.TestPersistent">
    <description>Test Persistent interface handling</description>
    <map-to table="test_oqlext" />
    <field name="id" type="integer">
      <sql name="ident"/>
    </field>
    <field name="ext" type="integer" required="true">
      <sql name="ext"/>
    </field>
    <field name="list" type="jdo.TestOqlExtends2" collection="collection"
           lazy="false">
      <sql many-table="test_oqltag" name="id2" many-key="id1"/>
    </field>
  </class>

  <class name="jdo.TestOqlExtends2" extends="jdo.TestPersistent">
    <description>Test Persistent interface handling</description>
    <map-to table="test_oqlext2" />
    <field name="ext" type="integer" required="true">
      <sql name="ext"/>
    </field>
  </class>

  <class name="jdo.TestCol" identity="id">
    <description>Table used for testing different collection types support</description>
    <cache-type type="none" />
    <map-to table="test_col" />
    <field name="id" type="integer">
      <sql name="id" type="integer" />
    </field>
    <!--
    <field name="dummy" type="integer" >
      <sql name="dum" type="integer" />
    </fild> -->
  </class>

  <class name="jdo.TestItem" identity="id">
    <description>Table used for testing different collection types support</description>
    <cache-type type="none" />
    <map-to table="test_item" />
    <field name="id" type="integer">
      <sql name="iid" type="integer" />
    </field>
    <field name="testCol" type="jdo.TestCol" >
      <sql name="id" />
    </field>
  </class>

  <class name="jdo.TestColArrayList" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="arraylist">
    </field>
  </class>

  <class name="jdo.TestColAdd" extends="jdo.TestCol">
    <description>Modification of TestCollArrayList to test manual addThing()</description>
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="arraylist" get-method="getItems" set-method="addItem">
    </field>
  </class>

  <class name="jdo.TestColArray" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="items" type="jdo.TestItem" collection="array">
    </field>
  </class>

  <class name="jdo.TestColCollection" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="collection">
    </field>
  </class>

  <!--
  <class name="jdo.TestColHashMap" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="hashmap">
    </field>
  </class>

  <class name="jdo.TestColHashSet" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="hashset">
    </field>
  </class>
  -->

  <class name="jdo.TestColHashtable" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always 
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="hashtable">
    </field>
  </class>

  <class name="jdo.TestColMap" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always 
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="map">
    </field>
  </class>

  <class name="jdo.TestColSet" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always 
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="set">
    </field>
  </class>

  <class name="jdo.TestColVector" extends="jdo.TestCol">
    <description>Table used for testing different collection types support</description>
    <!-- this is a dirty hack, don't follows. It only work if load always 
         done by db.load( MyClass.class, id ). -->
    <map-to table="test_col" />
    <field name="item" type="jdo.TestItem" collection="vector">
    </field>
  </class>

  <!-- Test many-to-many from entityA to entityB (but not from entityB to
       entityA) with lazy loading -->

  <class name="jdo.TestLazyNToNA" identity="idA">
    <description>Source table used for testing lazy loading many-to-many</description>
    <map-to table="test_nton_a" />
    <field name="idA" type="string"  required="true">
      <sql name="id" type="varchar" />
    </field>
    <field name="statusA" type="integer" required="true">
      <sql name="status" type="integer" />
    </field>
    <field name="refsToB" type="jdo.TestLazyNToNB" collection="collection" lazy="true" 
           set-method="setRefs" get-method="getRefs"/>
  </class>

  <class name="jdo.TestLazyNToNB" identity="idB">
    <description>Destination table used for testing lazy loading many-to-many</description>
    <map-to table="test_nton_a" />
    <field name="idB" type="string"  required="true">
      <sql name="id" type="varchar" />
    </field>
    <field name="statusB" type="integer" required="true">
      <sql name="status" type="integer" />
    </field>
  </class>

  <class name="jdo.Master" key-generator="MAX" identity="id">
    <map-to table="master" />
    <field name="depend1" type="jdo.Depend1">
      <sql name="depend1_id" />
      <bind-xml name="depend1" />
    </field>
    <field name="id" type="integer">
      <sql name="id" />
      <bind-xml name="id" />
    </field>
    <field name="depends2" collection="arraylist" type="jdo.Depend2">
      <sql many-key="master_id" />
      <bind-xml name="depends2" />
    </field>
  </class>

  <class name="jdo.Depend2" key-generator="MAX" depends="jdo.Master" identity="id">
    <map-to table="depend2" />
    <field name="master" type="jdo.Master">
      <sql name="master_id" />
      <bind-xml name="master" />
    </field>
    <field name="id" type="integer">
      <sql name="id" />
      <bind-xml name="id" />
    </field>
  </class>

  <class name="jdo.Depend1" key-generator="MAX" depends="jdo.Master" identity="id">
    <map-to table="depend1" />
    <field name="id" type="integer">
      <sql name="id" />
      <bind-xml name="id" />
    </field>
  </class>

  <class name="jdo.Brother" identity="id" key-generator="SEQUENCE">
    <map-to table="circ_brother" />
    <field name="id" type="long">
      <sql name="brother_id" type="integer" />
    </field>
    <field name="sister" type="jdo.Sister">
      <sql name="brother_sibling" />
    </field>
  </class>

  <class name="jdo.Sister" identity="id" key-generator="SEQUENCE">
    <map-to table="circ_sister" />
    <field name="id" type="long">
      <sql name="sister_id" type="integer" />
    </field>
    <field name="brother" type="jdo.Brother">
      <sql name="sister_sibling" />
    </field>
  </class>
  
  <!-- test objects for TestTransientAttribute -->
  <class name="jdo.TransientMaster" identity="id">
    <description>Entite one</description>
    <map-to table="trans_master" xml="entity1" />
    <field name="id" type="integer" >
      <sql name="id" type="integer"/>
    </field>
    <field name="name" type="string">
      <sql name="name" type="char" />
    </field>
    <field name="property1" type="integer">
      <sql name="propty1" type="integer" transient="true"/>
    </field>
    <field name="property2" type="integer">
      <sql name="propty2" type="integer"/>
    </field>
    <field name="property3" type="integer" transient="true">
      <sql name="propty3" type="integer"/>
    </field>
    <field name="entityTwo" type="jdo.TransientChildOne">
      <sql name="ent2" transient="true" />
    </field>
    <field name="entityThrees" type="jdo.TransientChildTwo" collection="collection">
      <sql many-key="entityOneId" transient="true" />
    </field>
  </class>

  <class name="jdo.TransientChildOne" identity="id">
    <description>Entite one</description>
    <map-to table="trans_child1" xml="entity1" />
    <field name="id" type="integer" >
      <sql name="id" type="integer"/>
    </field>
    <field name="description" type="string">
      <sql name="descr" type="char" />
    </field>
  </class>

  <class name="jdo.TransientChildTwo" identity="id">
    <description>Entite one</description>
    <map-to table="trans_child2" xml="entity1" />
    <field name="id" type="integer" >
      <sql name="id" type="integer"/>
    </field>
    <field name="description" type="string">
      <sql name="descr" type="char" />
    </field>
  </class>
  <!-- key generator definitions -->

</mapping>
