if (!
$definition instanceof EntityDefinition
) { throw new \
InvalidArgumentException('Definition must be an instance of EntityDefinition'
);
} $entity =
$definition->
getEntityName();
$escaped = EntityDefinitionQueryHelper::
escape($entity);
$query =
$this->connection->
createQueryBuilder();
$query->
from($escaped);
$query->
setMaxResults($limit);
if ($definition->
hasAutoIncrement()) { $query->
select([$escaped . '.auto_increment', 'LOWER(HEX(' .
$escaped . '.id)) as id'
]);
$query->
andWhere($escaped . '.auto_increment > :lastId'
);
$query->
addOrderBy($escaped . '.auto_increment'
);
$query->
setParameter('lastId', 0
);
if ($lastId !== null
) { $query->
setParameter('lastId',
$lastId['offset'
]);
} return new LastIdQuery($query);
}