DDC-3955: Adding a preInsert event #4837

Closed
opened 2026-01-22 14:50:20 +01:00 by admin · 1 comment
Owner

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 ?

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 ?
admin added the Improvement label 2026-01-22 14:50:20 +01:00
admin closed this issue 2026-01-22 14:50:20 +01:00
Author
Owner

@beberlei commented on GitHub (Feb 16, 2020):

You can use preFlush for this and check the entity is new I believe.

@beberlei commented on GitHub (Feb 16, 2020): You can use `preFlush` for this and check the entity is new I believe.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4837