<?xml version="1.0" encoding="UTF-8" ?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<orm xmlns="http://java.sun.com/xml/ns/jdo/orm"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/orm 
	http://java.sun.com/xml/ns/jdo/orm_2_1.xsd">
<!--
This file contains the schema information when an implementation
has application identity.
-->
    <package name="org.apache.jdo.tck.pc.companyMapWithoutJoin">

        <class name="Company" table="companies">
            <field name="companyid" column="ID"/>
            <field name="name" column="NAME">
              <column name="NAME" sql-type="VARCHAR"/>
            </field>
            <field name="founded" column="FOUNDEDDATE"/>
            <field name="departments" mapped-by="company"/>
        </class>

        <class name="Department" table="departments">
            <field name="deptid" column="ID"/>
            <field name="name" column="NAME"/>
            <field name="company" column="COMPANYID"/>
            <!-- field type is Map<String, Employee> -->
            <field name="roles" mapped-by="department">
                <key mapped-by="role"/>
            </field>
        </class>

        <class name="PartTimeEmployee">
            <inheritance strategy="superclass-table"/>
            <field name="wage" column="WAGE"/>
        </class>

        <class name="FullTimeEmployee">
            <inheritance strategy="superclass-table"/>
            <field name="salary" column="SALARY"/>
        </class>

        <class name="Employee">
            <inheritance strategy="superclass-table"/>
            <field name="hiredate" column="HIREDATE"/>
            <field name="weeklyhours" column="WEEKLYHOURS"/>
            <field name="role" column="ROLE"/>
            <field name="department" column="DEPARTMENT">
                        <foreign-key/>
            </field>
            <field name="fundingDept" column="FUNDINGDEPT">
                        <foreign-key/>
            </field>
            <field name="manager" column="MANAGER">
                        <foreign-key/>
            </field>
            <field name="mentor" column="MENTOR">
                        <foreign-key/>
            </field>
            <field name="protege" mapped-by="mentor"/>
            <field name="hradvisor" column="HRADVISOR">
                        <foreign-key/>
            </field>
            <field name="team" mapped-by="manager"/>
            <field name="hradvisees" mapped-by="hradvisor"/>
        </class>

        <class name="Person" table="persons">
            <inheritance strategy="new-table">
                <discriminator strategy="class-name" column="DISCRIMINATOR"
                    indexed="true"/>
            </inheritance>
            <field name="personid" column="PERSONID"/>
            <field name="firstname" column="FIRSTNAME"/>
            <field name="lastname" column="LASTNAME"/>
            <field name="middlename">
              <column name="MIDDLENAME" allows-null="true"/>
            </field>
            <field name="birthdate" column="BIRTHDATE"/>
        </class>

        <interface name="ICompany" table="companies">
            <property name="companyid" column="ID"/>
            <property name="name" column="NAME">
              <column name="NAME" sql-type="VARCHAR"/>
            </property>
            <property name="founded" column="FOUNDEDDATE"/>
            <property name="departments" mapped-by="company"/>
        </interface>

        <interface name="IDepartment" table="departments">
            <!-- field type is Map<String, Employee> -->
            <property name="roles" mapped-by="dept">
                <key mapped-by="role"/>
            </property>
            <property name="deptid" column="ID"/>
            <property name="name" column="NAME"/>
            <property name="company" column="COMPANYID"/>
        </interface>

        <interface name="IPartTimeEmployee">
            <inheritance strategy="superclass-table"/>
            <property name="wage" column="WAGE"/>
        </interface>

        <interface name="IFullTimeEmployee">
            <inheritance strategy="superclass-table"/>
            <property name="salary" column="SALARY"/>
        </interface>

        <interface name="IEmployee">
            <inheritance strategy="superclass-table"/>
            <property name="hiredate" column="HIREDATE"/>
            <property name="weeklyhours" column="WEEKLYHOURS"/>
            <property name="department" column="DEPARTMENT">
                        <foreign-key/>
            </property>
            <property name="fundingDept" column="FUNDINGDEPT">
                        <foreign-key/>
            </property>
            <property name="manager" column="MANAGER">
                        <foreign-key/>
            </property>
            <property name="mentor" column="MENTOR">
                        <foreign-key/>
            </property>
            <property name="protege" mapped-by="mentor"/>
            <property name="hradvisor" column="HRADVISOR">
                        <foreign-key/>
            </property>
            <property name="team" mapped-by="manager"/>
            <property name="hradvisees" mapped-by="hradvisor"/>
        </interface>

        <interface name="IPerson" table="persons">
            <inheritance strategy="new-table">
                <discriminator strategy="class-name" column="DISCRIMINATOR"
                    indexed="true"/>
            </inheritance>
            <property name="personid" column="PERSONID"/>
            <property name="firstname" column="FIRSTNAME"/>
            <property name="lastname" column="LASTNAME"/>
            <property name="middlename">
              <column name="MIDDLENAME" allows-null="true"/>
            </property>
        </interface>
    </package>
</orm>
