private function getQueryBuilder($locale, $locales, UserInterface $user = null)
    {
        $queryBuilder = new QueryBuilder($this->qomFactory);

        $queryBuilder
            ->select('node', 'jcr:uuid', 'uuid')
            ->addSelect('node', $this->getPropertyName('nodeType', $locale), 'nodeType')
            ->addSelect('node', $this->getPropertyName('internal_link', $locale), 'internalLink')
            ->addSelect('node', $this->getPropertyName('state', $locale), 'state')
            ->addSelect('node', $this->getPropertyName('shadow-on', $locale), 'shadowOn')
            ->addSelect('node', $this->getPropertyName('shadow-base', $locale), 'shadowBase')
            ->addSelect('node', $this->propertyEncoder->systemName('order'), 'order')
            ->from($this->qomFactory->selector('node', 'nt:unstructured'))
            ->orderBy($this->qomFactory->propertyValue('node', 'sulu:order'));

        $this->appendSingleMapping($queryBuilder, 'template', $locales);
        $this->appendSingleMapping($queryBuilder, 'shadow-on', $locales);
        $this->appendSingleMapping($queryBuilder, 'state', $locales);

        if (null !== $user) {
            foreach ($user->getRoleObjects() as $role) {
                $queryBuilder->addSelect(
                    'node',
                    sprintf('sec:%s', 'role-' . $role->getId()),
                    sprintf('role%s', $role->getId())
                );
            }
        }

        return $queryBuilder;
    }