7.1 About the unitofwork¶
The UnitOfWork’s role is to track object changes to persist it into database.
7.1.1 Internal process¶
The UnitOfWork initializes in all objects “managed” a property
tingUUID which must not in any way be altered by the user.
A “managed” object is an object that already exists in base and will cause UPDATE query when you ask it to be persisted.
We ask the UnitOfWork to persist the data. It can be an update, or a deletion.
The orders are generally stacked in the queue of UnitOfWork then you ask it to treat the whole in a single process.
$unitOfWork->pushSave($user1); $unitOfWork->pushSave($user2); $unitOfWork->pushDelete($user3); $unitOfWork->process();
Whether it’s to persist updating or inserting an entity you must use
Upon insertion of an entity which has an autoincrement property (configured in metadata) the autoincrement issued by the database will be set in the entity.
7.3 Notes for batch process¶
When processing a large number of items it is imperative to detach items that we don’t use anymore to free memory:
We are also able to detach all objects when they have been persisted: