You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bill Mulert <wd...@zygno.org> on 2002/12/15 18:08:38 UTC

foreign key question

In my scenario, I have class Foo which holds a reference to an instance
of class Bar. I have the repo setup so when Foo is loaded, its
asscocited Bar is loaded as well. My issue is, some instances of Foo do
not have a Bar associated with them. This causes an exception when I
store a Foo (OJB can't find a Bar with a matching key). I've looked
closely at the OJB DTD and it doesn't appear I can get the desired
behavior that seems so inituitive to me (ie, save the Foo but don't
attempt to match the Bar key if the Bar object is null).

Am I missing something obvious?

Here is the relevant part of the class descriptor for Foo:

      <field-descriptor id="11"
         name="atmID"
         column="Atmnt"
         jdbc-type="INTEGER"
      />
      <reference-descriptor
         name="attachment"
         class-ref="com.coolfactor.cen.BusinessObjects.Bar"
         auto-update="true"
         auto-delete="true">
         <foreignkey field-id-ref="11"/>
      </reference-descriptor>

regards to all --
-- bill