Я не нашел лучшего решения, поэтому я сделал переход:
$entityManager = $this->container->get('doctrine.orm.entity_manager');
$entities = $entityManager->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
foreach ($entities as $className) {
if ((strpos($className, "AppBundle") !== false) && (strpos($className, "Abstract") === false)) { //only my classes and no abstract class
$records = $entityManager->getRepository($className)->findAll();
$metadata = $entityManager->getClassMetadata($className);
$entity_fields = $metadata->getFieldNames();
foreach ($entity_fields as $field) {
$type = $metadata->getTypeOfField($field);
if ($type === "string") {
foreach ($records as $record) {
$oldValue = $metadata->getReflectionProperty($field)->getValue($record);
$metadata->getReflectionProperty($field)->setValue($record, " ");
$entityManager->persist($record);
$entityManager->flush();
$metadata->getReflectionProperty($field)->setValue($record, trim($oldValue));
$entityManager->persist($record);
$entityManager->flush();
}
}
}
}
}