protected function createSubQueryBuilder($select = null)
    {
        if (!$select) {
            $select = $this->getSelectAs($this->idField);
        }

        // get all filter-fields
        $filterFields = $this->getAllFields(true);

        // get entity names
        $entityNames = $this->getEntityNamesOfFieldDescriptors($filterFields);

        // get necessary joins to achieve filtering
        $addJoins = $this->getNecessaryJoins($entityNames);

        // create querybuilder and add select
        $queryBuilder = $this->createQueryBuilder($addJoins)->select($select);

        if ($this->user && $this->permission && array_key_exists($this->permission, $this->permissions)) {
            $this->addAccessControl(
                $queryBuilder,
                $this->user,
                $this->permissions[$this->permission],
                $this->securedEntityName,
                $this->encodeAlias($this->securedEntityName)
            );
        }

        return $queryBuilder;
    }