Using Transactions

Topic updated 11-10-2007

Transactions provide a mechanism in relational databases to treat multiple updates as one operation that either succeeds completely or fails completely. All updates that are part of a transaction are either committed or rolled back. This way consistency of data can be guaranteed. All databases supported by GenWise support database transactions.

The factory classes in a BO-Layer generated by GenWise encapsulate transactional behaviour.
 
The Factory Session Scope property will determine what's the behaviour. By default this property uses Explicit Transactions.
 
In cascading updates and collections updates the use of one transaction for multiple updates is completely automatic.

This topic explains how you can write code that uses a BO-Layer to create transactions spanning multiple update operations, multiple business objects and multiple factories.

 

Below are the different Techniques which can be used:

Explicit Transactions (recommended)
Implicit Transactions (Per Operation)
Implicit Transactions (Factory Scope)

 

 

FactoryScope is not needed in the case of a cascading update. In a cascading update a single operation leads to an update of one parent object along with all its child objects. In this case the factory class will automatically perform all operations in one transaction.