public function execute($parameters = null, $hydrationMode = null)
    {
        if (!empty($parameters)) {
            $this->setParameters($parameters);
        }

        if (null !== $hydrationMode) {
            $this->setHydrationMode($hydrationMode);
        }

        if (null !== $this->maxResults) {
            $this->query->setLimit($this->maxResults);
        }

        if (null !== $this->firstResult) {
            $this->query->setOffset($this->firstResult);
        }

        foreach ($this->parameters as $key => $value) {
            $this->query->bindValue($key, $value);
        }

        switch ($this->hydrationMode) {
            case self::HYDRATE_PHPCR:
                $data = $this->query->execute();
                break;
            case self::HYDRATE_DOCUMENT:
                $data = $this->dm->getDocumentsByPhpcrQuery($this->query, $this->documentClass, $this->primaryAlias);
                break;
            default:
                throw QueryException::hydrationModeNotKnown($this->hydrationMode);
        }

        if (is_array($data)) {
            $data = new ArrayCollection($data);
        }

        return $data;
    }