mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3955: Adding a preInsert event #4837
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Oct 18, 2015).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user etioun:
Hi guys !
I would like to perform some actions when a new entity is inserted in the database. The prePersist event is quite tricky because it is not called during the entity manager flush() like preUpdate, so if ever a new entity is modified between a persist() and a flush(), no life cycle events are triggered... What about adding a preInsert event that would be called just before a new entity is inserted in the DB ?
@beberlei commented on GitHub (Feb 16, 2020):
You can use
preFlushfor this and check the entity is new I believe.