Generally doctrine isn't aware of what happened at the DB level after flush as entities are managed in memory, Calling $entityManager->clear();
resolves this issue by clearing the identity map, forcing Doctrine to fetch fresh data from the database for subsequent operations.
https://stackoverflow.com/a/59970767/16742310