public function hydrate($model, array $fields = array())
    {
        if (is_array($model)) {
            return $this->getRepository($this->resolveModelClassName(reset($model)))->hydrate($model, $fields);
        }

        $row = $this->getRepository($this->resolveModelClassName($model))->hydrate(array($model), $fields);

        if (empty($row)) {
            return null;
        }

        return $row[0];
    }