Access to ObjectManager.CachedActions

I'd like to optimize my batches.
Our users are adding new Entities and revoking them within same CachedUpdate.

So I'd like to create our own children of TObjectManager, that can deal with this by just recognizing that the same Entity is inserted and deleted within the same batch.

Right now, I'm able to detect this with overriding

    function ExecuteInsertCommand(Entity: TObject; MasterObj: TMasterObjectValue): TInsertAction; virtual;
    function ExecuteDeleteCommand(Entity: TObject; CheckRowsAffected: Boolean): TDeleteAction; virtual;
    function ExecuteItemAddCommand(Entity: TObject; MasterObj: TMasterObjectValue): TUpdateAction; virtual;
    function ExecuteItemRemoveCommand(Entity: TObject; MasterObj: TMasterObjectValue): TUpdateAction; virtual;

But I'm not able to remove these actions from FCachedActions.

While we are just using ids and not composite ids, handle this is a little bit easier for us than you could :wink:

Another use case for this is VersionConcurrencyControl.
For changes that do not use CachedUpdates, we implemented an exceptionhandler, that recieves the current entity using a different ObjectManager from database.
Fetching OldState from current ObjectManager, so that we are able to get fieldchangelists.
If there are no intermediate changes of fields, we increment version to current entity.version and retry.
If there are intermediate changes, we are showing a merge form to our customer, so that he could choose, which values he would like to save.

For Batches VersionConcurrencyControlError occurs by applying batch, as it should.
Because OldState changes using save, flush etc. we are fetching OldState before batch starts.
So we are able to rebuild all flushes that has been done while batch is collecting.
But because old update statements stay in CachedActions, we could not continue our batch...

I understand you just need a protected access to the FCachedActions field?

That would be absolutely fine.
I don't need public access at all.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.