protected function loadData()
    {
        /** @var ActiveQuery $activeQuery */
        foreach ($this->relationalData as $attribute => &$data) {

            $getter = 'get' . ucfirst($attribute);
            $data['activeQuery'] = $activeQuery = $this->owner->$getter();
            $data['newModels'] = [];
            $data['oldModels'] = [];
            $data['newRows'] = [];
            $data['oldRows'] = [];

            if (!$this->validateOnCondition($activeQuery)) {
                Yii::$app->getDb()->getTransaction()->rollBack();
                throw new RelationException('ON condition for attribute ' . $attribute . ' must be associative array');
            }

            if ($activeQuery->multiple) {
                if (empty($activeQuery->via)) { // one-to-many
                    $this->loadModelsOneToMany($attribute);
                } else { // many-to-many
                    if ($activeQuery->via instanceof ActiveQueryInterface) { // viaTable
                        $this->loadModelsManyToManyViaTable($attribute);
                    } else { // via
                        $this->loadModelsManyToManyVia($attribute);
                    }
                }

            } elseif (!empty($data['data'])) {
                // one-to-one
                $this->loadModelsOneToOne($attribute);
            }

            if (empty($activeQuery->via)) {
                $data['oldModels'] = $activeQuery->all();
            }
            unset($data['data']);

            foreach ($data['newModels'] as $i => $model) {
                $data['newModels'][$i] = $this->replaceExistingModel($model, $attribute);
            }
        }
    }