Show TOC Start of Content Area

Function documentation Many-to-Many Unidirectional Generic Relationships  Locate the document in its SAP Library structure

Use

A many-to-many generic unidirectional relationship has a field of type java.util.Set with an interface element type or an object element type on one of the sides of the relationship.

In the relational model, there is a generic persistent reference in a join table that logically belongs to the class of the one side of the relationship.

 

Example

The class example.jdo.Employee contains field set with element type example.jdo.SomeInterface. There is a join table TMP_JOIN with the foreign key column EMPLOYEEcorresponding to the primary key column EMPID in table TMP_EMPLOYEE. The join table also contains the generic persistent reference that consists of the columns REF1DISC and REF1 for the discriminator and the reference.

 

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="set" persistence-modifier="persistent"

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

        <collection element-type="employee.jdo.SomeInterface" embedded-element="false"/>

      </field>

    </class>

  </package>

</jdo>

 

<map version="1.0">

  <package name="example.jdo">

    <class name="Employee">

      <field name="empid">

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

      </field>

      <relationship-field name="set" multiplicity="many" join-table="true">

        <foreign-key name="JOIN_TO_EMPLOYEE"

            foreign-key-table="TMP_JOIN" primary-key-table="TMP_EMPLOYEE">

          <column-pair foreign-key-column="EMPLOYEE" primary-key-column="EMPID"/>

        </foreign-key>

        <discriminator>

          <column name="REF1DISC" table="TMP_JOIN"/>

        </discriminator>

        <reference>

          <column name="REF1" table="TMP_JOIN"/>

        </reference>

      </relationship-field>

    </class>

  </package>

</map>

 

 

End of Content Area