private function setIdentifierFromAssociation($association, $key = '', $i = 0, $metadata = null)
    {
        if (null === $metadata) {
            $metadata = $this->metadata;
        }

        if (is_string($association)) {
            $targetEntityClass = $metadata->getAssociationTargetClass($association);
            $targetMetadata = $this->getMetadata($targetEntityClass);
            $this->selectColumns[$association][] = $this->getIdentifier($targetMetadata);
        }

        if (is_array($association) && array_key_exists($i, $association)) {
            $column = $association[$i];
            $count = count($association) - 1;
            if (true === $metadata->hasAssociation($column)) {
                $targetEntityClass = $metadata->getAssociationTargetClass($column);
                $targetMetadata = $this->getMetadata($targetEntityClass);
                if ($count == $i) {
                    $this->selectColumns[$key][] = $this->getIdentifier($targetMetadata);
                } else {
                    ++$i;
                    $this->setIdentifierFromAssociation($association, $key, $i, $targetMetadata);
                }
            }
        }

        return $this;
    }