protected function _authenticateCreateSelect()
    {
        if ($this->credentialTreatment === null) {
            $this->credentialTreatment = '?';
        }

        $select = sprintf(
            '(CASE WHEN e.%s = %s THEN 1 ELSE 0 END) as zend_auth_credential_match',
            $this->credentialColumn,
            str_replace('?', $this->getEm()->getConnection()->quote($this->credential), $this->credentialTreatment)
        );

        $qb = $this->em->createQueryBuilder()
                       ->select($select)
                       ->from($this->entityName, 'e')
                       ->where('e.' . $this->identityColumn . ' = :identity');

        $parameters = array('identity' => $this->getIdentity());
        foreach ($this->conditions as $condition => $params) {
            $qb->andWhere('e.' . $condition);
            $parameters = array_merge($parameters, $params);
        }

        $qb->setParameters($parameters);

        return $qb->getQuery();
    }