public function getReference($name)
    {
        if (!isset($this->_manager)) {
            throw new RepositoryException('Model is not handled by a managed repository');
        }
        if (array_key_exists($name, $this->_references)) {
            $ref = $this->_references[$name];
            $repo = $this->_manager->getByClass($ref['model']);
            if (!$repo) {
                throw new RepositoryException('Referenced model is not handled by a managed repository');
            }
            return ($repo->find($ref['key'], $this->{$ref['attribute']}) ?: null);
        }
        return null;
    }