7   UnitOfWork

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.

7.2   Principle

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.


7.2.1   Specifity

Whether it’s to persist updating or inserting an entity you must use pushSave.

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: