-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot persist an entity during onFlush #11892
Comments
Not sure it is related, not doing any |
I think I found the reason why it do fails I had to manually persist these relations to in order to make it work foreach ($event->getRelations() as $relation) {
$entityManager->persist($relation);
$unitOfWork->computeChangeSet($eventRelationMetadata, $relation);
} yann-eugone/doctrine-persist-in-onflush@5dac0ce I still have no idea how to fix the |
I believe I've found a solution to the problem I've faced Is still believe that the error was very unclear |
Bug Report
Summary
Not able to persist a new entity in the
onFlush
listener.Current behavior
When using
EntityManager::persist()
along withUnitOfWork::computeChangeSet()
, I get aSQL syntax error
: the insert query does not have any parameter bound.When using
Collection::add()
along withUnitOfWork::recomputeSingleEntityChangeSet()
, nothing happens: the entity is never saved.Expected behavior
Regarding the documentation, we should be able to persist new entities, on their own, or using collections:
How to reproduce
I created a pretty simple project with my use case
https://github.com/yann-eugone/doctrine-persist-in-onflush
The idea is that I have a
AuditEvent
entity that should be created every time an entity is updated.The text was updated successfully, but these errors were encountered: