docs: private void addForeignkeys(ReferenceDescriptorDef refDef, TableDef tableDef)
      {
          if (!refDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_DATABASE_FOREIGNKEY, true))
          {
              // we shall not generate a database foreignkey
              return;
          }
  
          // a foreignkey is added to the table schema if
          // the referenced table exists (i.e. the referenced type has an associated table)
          // then the foreignkey consists of:
          //   remote table  = table of referenced type
          //   local fields  = foreignkey fields of the reference 
          //   remote fields = primarykeys of the referenced type
          ClassDescriptorDef ownerClassDef      = (ClassDescriptorDef)refDef.getOwner();
          String             targetClassName    = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
          ClassDescriptorDef referencedClassDef = ((ModelDef)ownerClassDef.getOwner()).getClass(targetClassName);
  
          // we can add a foreignkey only if the target type and all its subtypes either
          // map to the same table or do not map to a table at all
          String tableName = getHierarchyTable(referencedClassDef);
  
          if (tableName == null)
          {
              return;
          }
  
          try
          {
              String    name         = refDef.getName();
              ArrayList localFields  = ownerClassDef.getFields(refDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY));
              ArrayList remoteFields = referencedClassDef.getPrimaryKeys();
  
              tableDef.addForeignkey(name, tableName, getColumns(localFields), getColumns(remoteFields));
          }
          catch (NoSuchFieldException ex)
          {
              // won't happen if we already checked the constraints
          }
      }