Reputation: 222
From the Doctrine2 documentation:
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.
I'm still in doubt about transactions, say that i have 5 persist operations to do in a transaction, does the postPersist
event be called after every persist or just after the transaction commit?
Upvotes: 1
Views: 1006
Reputation: 44422
It is called for every entity that is inserted in the database.
Even for new entities that are persisted because of a cascade operation (set in your association with cascade={"persist"}
) the postPersist
event is fired.
The event is triggered here in the executeInserts
method in the Doctrine\ORM\UnitOfWork
, so literally for all inserts.
Upvotes: 1