#1 mORMot 2 » TRestBatch multi-table atomic transaction » 2026-04-22 14:13:31

Reco
Replies: 1

Hello,

I am using mORMot 2 with SQLite3 and I need to perform 3 operations
atomically across different ORM classes:
  - Add() to TInvoice
  - Update() to TSupplier 
  - Add() to TShipment

I am using TRestBatch with nil class like this:

  Batch := TRestBatch.Create(Rest.ORM, nil, 0);
  Batch.Add(InvoiceItem, True);
  Batch.Update(SupplierRec);
  Batch.Add(ShipmentItem, True);
  Rest.ORM.BatchSend(Batch);

My questions:
1. Is TRestBatch with nil class truly atomic across multiple tables?
2. Does BatchSend wrap everything in a single SQLite BEGIN/COMMIT transaction?
3. How long does it lock the DB for other concurrent users?
4. Is there a better approach for multi-table all-or-nothing operations?

Thank you

Board footer

Powered by FluxBB