Entering content frame

Function documentation Mapping to One Table Locate the document in its SAP Library structure

Use

In this scenario, all fields of all classes in the class hierarchy are mapped to a single table. The columns corresponding to the fields declared in the subclasses must allow null values.

Example

There is an inheritance hierarchy with three classes. Class example.jdo.Manager and class example.jdo.Subordinate both inherit from class example.jdo.Employee. The root class example.jdo.Employee contains a key field empid. All classes have a private field name. All classes and fields are mapped to table TMP_INHERITANCE, the key field empid is mapped to column EMPID, and the name fields are mapped to columns NAME1, NAME2 and NAME3. In table TMP_INHERITANCE, there is a discriminator column DISC containing the type of a table row.

 

This graphic is explained in the accompanying text

 

The XML metadata has the following contents:

 

<jdo>

  <package name="example.jdo">

    <class name="Employee" identity-type="application" objectid-class="Employee$Id">

      <field name="empid" persistence-modifier="persistent" primary-key="true"/>

      <field name="name" persistence-modifier="persistent"

        embedded="false" default-fetch-group="true"/>

    </class>

    <class name="Manager" identity-type="application" objectid-class="Employee$Id">

      <field name="name" persistence-modifier="persistent"

        embedded="false" default-fetch-group="true"/>

    </class>

    <class name="Subordinate" identity-type="application" objectid-class="Employee$Id">

      <field name="name" persistence-modifier="persistent"

        embedded="false" default-fetch-group="true"/>

    </class>

  </package>

</jdo>

 

<map version="1.0">

  <package name="example.jdo">

    <class name="Employee">

      <discriminator>

        <column name="DISC" table="TMP_INHERITANCE"/>

      </discriminator>

      <field name="empid">

        <column name="EMPID" table="TMP_INHERITANCE"/>

      </field>

      <field name="name">

        <column name="NAME1" table="TMP_INHERITANCE"/>

      </field>

    </class>

    <class name="Manager">

      <field name="name">

        <column name="NAME2" table="TMP_INHERITANCE"/>

      </field>

    </class>

    <class name="Subordinate">

      <field name="name">

        <column name="NAME3" table="TMP_INHERITANCE"/>

      </field>

    </class>

  </package>

</map>

 

See also:

 

Mapping to Separate Tables

 

Leaving content frame