<?xml version="1.0" ?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                         "http://castor.org/mapping.dtd">
<mapping>
    
    <class name="ctf.jdo.tc8x.SelfReferentialParent" identity="id">
        <map-to table="tc8x_self_refer_parent" xml="entity1" />
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="parent" type="ctf.jdo.tc8x.SelfReferentialParent" >
            <sql name="fid"/>
        </field>
        <field name="name" type="string" required="true">
            <sql name="name" type="char" />
        </field>
        <field name="entities" type="ctf.jdo.tc8x.SelfReferentialParent" 
            collection="arraylist">
            <sql many-key="fid" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.SelfReferentialChild" identity="id" extends="ctf.jdo.tc8x.SelfReferentialParent">
        <map-to table="tc8x_self_refer_child" xml="child" />
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="description" type="string" required="true">
            <sql name="descr" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.MasterObject" identity="id" key-generator="IDENTITY">
        <map-to table="tc8x_test_master_ns" />
        <field name="id" type="int">
            <sql name="id"/>
        </field>
        <field name="depends" type="ctf.jdo.tc8x.DependentObject">
            <sql many-key="master_id"/>
        </field>
        <field name="descrip" type="string" required="true">
            <sql name="descrip" type="varchar"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.DependentObject" identity="id" key-generator="IDENTITY"
           depends="ctf.jdo.tc8x.MasterObject">
        <map-to table="tc8x_test_depends_ns"/>
        <field name="id" type="int">
            <sql name="id"/>
        </field>
        <field name="master" type="ctf.jdo.tc8x.MasterObject">
            <sql name="master_id"/>
        </field>
        <field name="descrip" type="string">
            <sql name="descrip" type="varchar"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.MasterObjectNoKeyGen" identity="id">
        <map-to table="tc8x_test_master_ns_nokg" />
        <field name="id" type="int">
            <sql name="id"/>
        </field>
        <field name="depends" type="ctf.jdo.tc8x.DependentObjectNoKeyGen">
            <sql many-key="master_id"/>
        </field>
        <field name="descrip" type="string">
            <sql name="descrip" type="varchar"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.DependentObjectNoKeyGen" identity="id"
           depends="ctf.jdo.tc8x.MasterObjectNoKeyGen">
        <map-to table="tc8x_test_depends_ns_nokg"/>
        <field name="id" type="int">
            <sql name="id"/>
        </field>
        <field name="master" type="ctf.jdo.tc8x.MasterObjectNoKeyGen" required="true">
            <sql name="master_id"/>
        </field>
        <field name="descrip" type="string" required="true">
            <sql name="descrip" type="varchar"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.Parent">
        <map-to table="tc8x_parent" />
        <field name="id" type="integer" identity="true">
            <sql name="id" type="integer"/>
        </field>
        <field name="name" type="string">
            <sql name="name" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.Child" extends="ctf.jdo.tc8x.Parent">
        <map-to table="tc8x_child" />
        <field name="id" type="integer" identity="true">
            <sql name="id" type="integer"/>
        </field>
        <field name="description" type="string">
            <sql name="descr" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.ParentWithCompoundId">
        <map-to table="tc8x_parent_compound" />
        <field name="id1" type="integer" identity="true">
            <sql name="id1" type="integer"/>
        </field>
        <field name="id2" type="integer" identity="true">
            <sql name="id2" type="integer"/>
        </field>
        <field name="name" type="string" required="true">
            <sql name="name" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.ChildWithCompoundId" extends="ctf.jdo.tc8x.ParentWithCompoundId">
        <map-to table="tc8x_child_compound" />
        <field name="id1" type="integer" identity="true">
            <sql name="id1" type="integer"/>
        </field>
        <field name="id2" type="integer" identity="true">
            <sql name="id2" type="integer"/>
        </field>
        <field name="description" type="string" required="true">
            <sql name="descr" type="varchar" />
        </field>
    </class>



    <class name="ctf.jdo.tc8x.TransientMaster" identity="id">
        <map-to table="tc8x_trans_master"/>
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="name" type="string" required="true">
            <sql name="name" type="varchar"/>
        </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="ctf.jdo.tc8x.TransientChildOne">
            <sql name="ent2" transient="true"/>
        </field>
        <field name="entityThrees" type="ctf.jdo.tc8x.TransientChildTwo" collection="collection">
            <sql many-key="entityOneId" transient="true"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.TransientChildOne" identity="id">
        <map-to table="tc8x_trans_child1" xml="entity1" />
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="description" type="string" required="true">
            <sql name="descr" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.TransientChildTwo" identity="id">
        <map-to table="tc8x_trans_child2" xml="entity1" />
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="description" type="string" required="true">
            <sql name="descr" type="varchar" />
        </field>
    </class>
    
    <class name="ctf.jdo.tc8x.Product" identity="id">
        <map-to table="tc8x_enum_prod"/>
        <field name="id" type="integer">
            <sql name="id" type="integer" />
        </field>
        <field name="name" type="string" required="true">
            <sql name="name" type="varchar" />
        </field>
        <field name="kind" type="ctf.jdo.tc8x.KindEnum" required="true">
            <sql name="kind" type="varchar" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.CircBrother" identity="id" key-generator="SEQUENCE">
        <map-to table="tc8x_circ_brother" />
        <field name="id" type="long">
            <sql name="brother_id" type="integer" />
        </field>
        <field name="sister" type="ctf.jdo.tc8x.CircSister">
            <sql name="brother_sibling" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.CircSister" identity="id" key-generator="SEQUENCE">
        <map-to table="tc8x_circ_sister" />
        <field name="id" type="long">
            <sql name="sister_id" type="integer" />
        </field>
        <field name="brother" type="ctf.jdo.tc8x.CircBrother">
            <sql name="sister_sibling" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.Lazy1to1Parent" identity="id">
        <map-to table="tc8x_lazy_11_par" />
        <field name="id" type="integer" >
            <sql name="id" type="integer"/>
        </field>
        <field name="description" type="string" required="true">
            <sql name="descr" type="varchar"/>
        </field>
        <field name="child" type="ctf.jdo.tc8x.Lazy1to1Child" lazy="true">
            <sql name="child_id" />
        </field>
    </class>
  
    <class name="ctf.jdo.tc8x.Lazy1to1Child" identity="id" >
        <map-to table="tc8x_lazy_11_chd" />
        <field name="id" type="integer" >
            <sql name="id" type="integer" />
        </field>
        <field name="description" type="string">
            <sql name="descr" type="varchar" />
        </field>
    </class>
  
    <class name="ctf.jdo.tc8x.Lazy1to1Author" identity="id">
        <cache-type type="unlimited" capacity="0"/>
        <map-to table="tc8x_lazy_11_author"/>
        <field name="id" type="long">
            <sql name="ID" type="bigint"/>
        </field>
        <field name="firstName" type="string" required="true">
            <sql name="FIRST_NAME" type="varchar"/>
        </field>
        <field name="lastName" type="string" required="true">
            <sql name="LAST_NAME" type="varchar"/>
        </field>
        <field name="books" type="ctf.jdo.tc8x.Lazy1to1Book" lazy="true" collection="collection">
            <sql many-key="ID"/>
        </field>
    </class>
	
    <class name="ctf.jdo.tc8x.Lazy1to1Book" identity="id">
        <cache-type type="unlimited" capacity="0"/>
        <map-to table="tc8x_lazy_11_book"/>
        <field name="id" type="long">
            <sql name="ID" type="bigint"/>
        </field>
        <field name="name" type="string" required="true">
            <sql name="NAME" type="varchar"/>
        </field>
        <field name="author" type="ctf.jdo.tc8x.Lazy1to1Author" required="true" lazy="true">
            <sql name="AUTHOR_ID"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.LazyPerson" identity="firstName lastName">
        <description>Table used for testing lazy loading</description>
        <map-to table="tc8x_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="ctf.jdo.tc8x.LazyAddress" collection="collection" lazy="true" 
               set-method="setAddress" get-method="getAddress"/>
    </class>

    <class name="ctf.jdo.tc8x.LazyAddress" depends="ctf.jdo.tc8x.LazyPerson" identity="id">
        <description>Table used for testing lazy loading</description>
        <map-to table="tc8x_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="ctf.jdo.tc8x.LazyPerson">
            <sql name="fname lname"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.LazyEmployee" extends="ctf.jdo.tc8x.LazyPerson">
        <description>Table used for testing lazy loading for extends</description>
        <map-to table="tc8x_pks_employee" />
        <field name="startDate" type="date" >
            <sql name="start_date" type="date" />
        </field>
        <field name="payRoll" type="ctf.jdo.tc8x.LazyPayRoll" />
        <field name="contract" type="ctf.jdo.tc8x.LazyContract" />
        <field name="projects" type="ctf.jdo.tc8x.LazyProject" collection="collection" lazy="true"/>
    </class>

    <class name="ctf.jdo.tc8x.LazyProject" identity="id">
        <description>Table used for testing lazy loading</description>
        <map-to table="tc8x_pks_project" />
        <field name="id" type="integer">
            <sql name="id" type="integer" />
        </field>
        <field name="owner" type="ctf.jdo.tc8x.LazyEmployee">
            <sql name="fname lname"/>
        </field>
        <field name="name" type="string">
            <sql name="name" type="varchar"/>
        </field>
    </class>

    <class name="ctf.jdo.tc8x.LazyContract" depends="ctf.jdo.tc8x.LazyEmployee" identity="policyNo contractNo">
        <description>Table used for testing multiple primary keys for extends</description>
        <map-to table="tc8x_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="ctf.jdo.tc8x.LazyContractCategory" collection="collection" >
            <sql many-table="tc8x_pks_category_contract" many-key="policy_no contract_no" name="cate_id" />
        </field>
        <field name="employee" type="ctf.jdo.tc8x.LazyEmployee" >
            <sql name="fname lname" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.LazyContractCategory" identity="id" >
        <map-to table="tc8x_pks_category" />
        <field name="id" type="integer">
            <sql name="id" type="integer" />
        </field>
        <field name="name" type="string" required="true">
            <sql name="name" type="varchar" />
        </field>
        <field name="contract" type="ctf.jdo.tc8x.LazyContract" collection="collection" >
            <sql many-table="tc8x_pks_category_contract" many-key="cate_id" name="policy_no contract_no" />
        </field>
    </class>

    <class name="ctf.jdo.tc8x.LazyPayRoll" depends="ctf.jdo.tc8x.LazyEmployee" identity="id">
        <description>Table used for testing lazy loading</description>
        <map-to table="tc8x_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="ctf.jdo.tc8x.LazyEmployee" >
            <sql name="fname lname" />
        </field>
    </class>
    
    <class name="ctf.jdo.tc8x.LazyNToNA" identity="idA">
        <description>Source table used for testing lazy loading many-to-many</description>
        <map-to table="tc8x_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="ctf.jdo.tc8x.LazyNToNB" collection="collection" lazy="true" 
               set-method="setRefs" get-method="getRefs"/>
    </class>

    <class name="ctf.jdo.tc8x.LazyNToNB" identity="idB">
        <description>Destination table used for testing lazy loading many-to-many</description>
        <map-to table="tc8x_nton_b" />
        <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>
</mapping>
