Acquire SQL Statements from TObjectManager before execution

Hello

Is it possible to capture the SQL that would be generated by the TObjectManager on a call to Save, similar the the way a SQL Script can be obtained from the TDatabaseManager? I ask because I am running Aurelius against a 'Serverless' MySQL server. This works, but can be very time-consuming as each individual SQL statement requires a round trip to the server via HTTP. As a result, saving a single object can take up to a minute because of the number of statments executed. The Save operation runs in the background, but sometimes requires additional management (eg assuring all statements have executed before allowing app to quit). If I could acquire all of the SQL statements to be generated for a given Save operation I could send those statements to the server as a batch, thereby greatly reducing their execution time and lowering my risk.

Thanks

1 Like

Hi,

You can capture SQL statements simply using TAureliusModelEvents component. Or you can subscribe to TMappingExplorer events or use new v5 attributes.

More info: https://doc.tmssoftware.com/biz/aurelius/guide/events.html

About batch operations, you can enable the Object Manager CachedUpdates and set BatchSize property so the operations (Save, Flush, Remove) will be executed in a batch after calling ApplyUpdates. Bulk operations behavior is dependent on the DB driver used.

More info: https://doc.tmssoftware.com/biz/aurelius/guide/objects.html?q=Cachedupdates

Regards,

1 Like

In addition to what @Farias_Anderson wrote, you can also set SimulateStatements to True in global configuration, thus the SQL statements will not be executed, but be provided in the events:

1 Like