code: private void ensureFields(ClassDescriptorDef classDef, Collection fields) throws ConstraintException
      {
          boolean forceVirtual = !classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true);
  
          for (Iterator it = fields.iterator(); it.hasNext();)
          {
              FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();
  
              // First we check whether this field is already present in the class
              FieldDescriptorDef foundFieldDef = classDef.getField(fieldDef.getName());
  
              if (foundFieldDef != null)
              {
                  if (isEqual(fieldDef, foundFieldDef))
                  {
                      if (forceVirtual)
                      {
                          foundFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
                      }
                      continue;
                  }
                  else
                  {
                      throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                              " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                              " because there is already a different field of the same name");
                  }
              }
  
              // perhaps a reference or collection ?
              if (classDef.getCollection(fieldDef.getName()) != null)
              {
                  throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                                                " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                                                " because there is already a collection of the same name");
              }
              if (classDef.getReference(fieldDef.getName()) != null)
              {
                  throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                                                " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                                                " because there is already a reference of the same name");
              }
              classDef.addFieldClone(fieldDef);
              classDef.getField(fieldDef.getName()).setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
          }
      }
docs: Ensures that the specified fields are present in the given class.
  
  @param classDef The class to copy the fields into
  @param fields   The fields to copy
  @throws ConstraintException If there is a conflict between the new fields and fields in the class