difference between postUpdate and postPersist in doctrine difference between postUpdate and postPersist in doctrine database database

difference between postUpdate and postPersist in doctrine


Because you should handle some logic only on update for example.And from doctrine's docs:

postPersist - The postPersist event occurs for an entity after the entity has been made persistent. It will be invoked after the database insert operations. Generated primary key values are available in the postPersist event.

postUpdate - The postUpdate event occurs after the database update operations to entity data. It is not called for a DQL UPDATE statement.

Do you see the difference now? The postPersist event is launched only after INSERT operations.