hi tim,

<inverse-foreignkey field-id-ref="1"/>
<inverse-foreignkey field-id-ref="2"/>

references the fields identified by id "1" and "2" in the other class,in
your sample "anotherfield1" and "anotherfield2"

hth
jakob

----- Original Message -----
From: "Gibbs, Tim" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 09, 2002 4:56 PM
Subject: One to Many with Compound Key



Now after digging for documentation I managed to get a m:n working pretty
easily with the intermediate table in a schema. But I am confused about a
1:n mapping working with just two tables that both have compound keys.  For
example I have:


   <class-descriptor
     class="com.MyTable1Class"
     table="Table1"
   >

       <field-descriptor id="1"
         name="field1"
         column="field1"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="false"
      />
      <field-descriptor id="2"
         name="field2"
         column="field2"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="false"
      />
      <field-descriptor id="3"
         name="field3"
         column="field3"
         jdbc-type="VARCHAR"
      />
     <collection-descriptor
         name="collectionOfStuffFromTable2"
         element-class-ref="com.MyTable2Class"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true"
      >
<inverse-foreignkey field-id-ref="1"/>
<inverse-foreignkey field-id-ref="2"/>
      </collection-descriptor>
</class-descriptor>

   <class-descriptor
     class="com.MyTable2Class"
     table="Table2"
   >

       <field-descriptor id="1"
         name="anotherfield1"
         column="anotherfield1"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="false"
      />
      <field-descriptor id="2"
         name="anotherfield2"
         column="anotherfield2"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="false"
      />
      <field-descriptor id="3"
         name="anotherfield3"
         column="anotherfield3"
         jdbc-type="VARCHAR"
         primarykey="true"
         autoincrement="false"
      />

</class-descriptor>

My understanding of the documentation in the dtd is that the
inverse-foreignkey elements refer to the field id in Table 2 but I am
confused as to how OJB knows that field1 in Table1Class maps to the column
specified by field-id-ref="1"??  Does it have to do with the order in which
the primary keys specified in the Table1Class descriptor?

Incidentally, I think I have it working, I am just curious about how it
knows to map field1 to anotherfield1 and field2 to anotherfield2.

Long mail for probably a simple question.

Thanks

Tim




<font face="Times New Roman" size="3">
<p>-------------------------------------------------------------------------
-----</p>
<p> This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in error,
please advise me (by return e-mail or otherwise) immediately.</p>
<p> Ce courriel est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux
droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou
copie de ce message ou des renseignements qu'il contient par une personne
autre que le (les) destinataire(s) d�sign�(s) est interdite. Si vous recevez
ce courriel par erreur, veuillez m'en aviser imm�diatement, par retour de
courriel ou par un autre moyen.</p>
<p>====================================================</p>
</font>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to