public function generateKey($includeHash = true)
    {
        $keys = array();

        $keys['vars'] = get_object_vars($this);
        $keys['class'] = get_class($this);
        $keys['metadata'] = $this->repository->getMetadata();
        $keys['dbname'] = $this->repository->getConnection()->getDbName();

        unset($keys['vars']['repository']);
        if ( !$includeHash ) unset($keys['vars']['hash']);
        return md5(serialize($keys));
    }