Transactions
xTransaction in WHO with passing down to all BusObjects (BusinessObjects). The WHO should have the responsability for commit/rollback. Each BusinessObject should issue an exception in case of an error and this exception should be caught by the WHO. This will allow multi-level BusinessObjects working together without suppressing the real exception on an intermediary level (by a âparentâ BusinessObject).
Each WHO has a property called âTransactionCreateâ (preset on TRUE) which:
creates a transaction-object (called âTransactionâ) when a module is opened and applies it to its BusinessObject
the Save method from the base class automatically commits the transaction
when the module is closed that transaction calls the dispose method
âTransactionCreateâ will be set on FALSE (in the constructor) if the module:
does not work with the database
is an internal module (xModule)
is response module and receives the transaction from the parent context
does not require transactions for any other reason
Notice that one response Module could have TransactionCreate set on true, because while opening a module using OpenResponseModule with Transaction as parameter, it will automatically set TransactionCreate on false and will pass the Transaction of the parent.
Each action done in the WHO needs to commit its changes. The handling of the exception is done in the WHO.
Best practice: The BusinessObjects should not return negative values for errors. Instead, exceptions, containing all the details about the error, should be thrown.
Example: Steps to implement for proper transaction management:
In the constructor of the WHO specify that a transaction is needed. This is all that has to be done. This transaction is passed on to the BusObj, which then gives it to its children, and so onâŚ
The Method inside the WHO should look like this:
To create a busObj inside a busObj, use the Function âCreateChildBusinessObjectâ. This way, the transaction is passed on to this new Object.
Example:
Using current object transaction to do other sql operations
Note: CurrentTransaction is obsolete, Transaction is the new name of the transaction property
Last updated