protected function fetchAsObject(Statement $stmt)
    {
        $stmt->setFetchMode(\PDO::FETCH_CLASS, $this->model->entity());
        $result = $stmt->fetchAll();

        $ref = new \ReflectionClass($this->model->entity());
        foreach ($result as $entity) {
            $this->restoreObject($entity, $this->casts, $ref);
        }

        return $result;
    }