public function attachSubDataObjects(
        $name,
        SwatDBRecordsetWrapper $sub_data_objects
    ) {
        if ($sub_data_objects->index_field === null) {
            throw new SwatDBException(
                sprintf(
                    'Index field must be specified in the sub-data-object ' .
                        'recordset wrapper class (%s::init()) ' .
                        'in order to attach recordset as sub-dataobjects.',
                    get_class($sub_data_objects)
                )
            );
        }

        foreach ($this->objects as $object) {
            $value = $object->getInternalValue($name);
            if (isset($sub_data_objects[$value])) {
                $object->$name = $sub_data_objects[$value];
            }
        }
    }