当刷新多个持续存在时,有没有办法确定负责UniqueConstraintViolationException
的实体?
$entityManager->persist($entity1);
$entityManager->persist($entity2);
$entityManager->persist($entity3);
...
$entityManager->persist($entity100);
try {
$entityManager->flush();
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
// Which entities were responsible for the violation?
}
我很感激我可以在每次坚持后刷新,但是我正在对它们进行批处理以减少对数据库的调用。