code: public void link(Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds, Object referencedObject, boolean insert)
      {
          // MBAIRD: we have 'disassociated' this object from the referenced object,
          // the object represented by the reference descriptor is now null, so set
          // the fk in the target object to null.
          // arminw: if an insert was done and ref object was null, we should allow
          // to pass FK fields of main object (maybe only the FK fields are set)
          if (referencedObject == null)
          {
              /*
              arminw:
              if update we set FK fields to 'null', because reference was disassociated
              We do nothing on insert, maybe only the FK fields of main object (without
              materialization of the reference object) are set by the user
              */
              if(!insert)
              {
                  unlinkFK(targetObject, cld, rds);
              }
          }
          else
          {
              setFKField(targetObject, cld, rds, referencedObject);
          }
      }
docs: Assign FK value to target object by reading PK values of referenced object.
  
  @param targetObject real (non-proxy) target object
  @param cld {@link ClassDescriptor} of the real target object
  @param rds An {@link ObjectReferenceDescriptor} or {@link CollectionDescriptor}
  associated with the real object.
  @param referencedObject referenced object or proxy
  @param insert Show if "linking" is done while insert or update.