docs: private void ensureReferencedPKs(ModelDef modelDef, CollectionDescriptorDef collDef) throws ConstraintException
      {
          String             elementClassName   = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
          ClassDescriptorDef elementClassDef    = modelDef.getClass(elementClassName);
          String             indirTable         = collDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE);
          String             localKey           = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
          String             remoteKey          = collDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY);
          boolean            hasRemoteKey       = remoteKey != null;
          ArrayList          fittingCollections = new ArrayList();
  
          // we're checking for the fitting remote collection(s) and also
          // use their foreignkey as remote-foreignkey in the original collection definition
          for (Iterator it = elementClassDef.getAllExtentClasses(); it.hasNext();)
          {
              ClassDescriptorDef subTypeDef = (ClassDescriptorDef)it.next();
  
              // find the collection in the element class that has the same indirection table
              for (Iterator collIt = subTypeDef.getCollections(); collIt.hasNext();)
              {
                  CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)collIt.next();
  
                  if (indirTable.equals(curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE)) &&
                      (collDef != curCollDef) &&
                      (!hasRemoteKey || CommaListIterator.sameLists(remoteKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY))) &&
                      (!curCollDef.hasProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY) ||
                           CommaListIterator.sameLists(localKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY))))
                  {
                      fittingCollections.add(curCollDef);
                  }
              }
          }
          if (!fittingCollections.isEmpty())
          {
              // if there is more than one, check that they match, i.e. that they all have the same foreignkeys
              if (!hasRemoteKey && (fittingCollections.size() > 1))
              {
                  CollectionDescriptorDef firstCollDef = (CollectionDescriptorDef)fittingCollections.get(0);
                  String                  foreignKey   = firstCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
  
                  for (int idx = 1; idx < fittingCollections.size(); idx++)
                  {
                      CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
  
                      if (!CommaListIterator.sameLists(foreignKey, curCollDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY)))
                      {
                          throw new ConstraintException("Cannot determine the element-side collection that corresponds to the collection "+
                                                        collDef.getName()+" in type "+collDef.getOwner().getName()+
                                                        " because there are at least two different collections that would fit."+
                                                        " Specifying remote-foreignkey in the original collection "+collDef.getName()+
                                                        " will perhaps help");
                      }
                  }
                  // store the found keys at the collections
                  collDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, foreignKey);
                  for (int idx = 0; idx < fittingCollections.size(); idx++)
                  {
                      CollectionDescriptorDef curCollDef = (CollectionDescriptorDef)fittingCollections.get(idx);
  
                      curCollDef.setProperty(PropertyHelper.OJB_PROPERTY_REMOTE_FOREIGNKEY, localKey);
                  }
              }
          }
  
          // copy subclass pk fields into target class (if not already present)
          ensurePKsFromHierarchy(elementClassDef);
      }