protected function doBatchDelete(ProxyQueryInterface $queryProxy)
{
$modelManager = $this->admin->getModelManager();
$class = $this->admin->getClass();
$queryProxy->select('DISTINCT ' . $queryProxy->getRootAlias());
try {
$entityManager = $modelManager->getEntityManager($class);
$i = 0;
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$entityManager->remove($object[0]);
if (++$i % 20 == 0) {
$entityManager->flush();
$entityManager->clear();
}
}
$entityManager->flush();
$entityManager->clear();
} catch (\PDOException $e) {
throw new ModelManagerException('', 0, $e);
} catch (DBALException $e) {
throw new ModelManagerException('', 0, $e);
}
}