Previous Topic

Book Contents

Book Index

Next Topic

Working with Objects in Transactions

We can distinguish two different types of transactions:

  • User – created by user prior to working with objects.
  • Internal – created automatically by the system, when you call methods that work with the objects in the database but you don’t pass your own user transaction as parameter. However, there are limitations regarding those operations that would entail changes in the database. In such case internal transactions are not used.

Create your own user transaction using Application.createTransaction before performing operations that entail changes to the database. If the operation is read-only (retrieving information, like getBOTypes), you don’t need to create your own transaction; an internal one will be created automatically on calling the method.

If you are about to make changes to objects, the operations should be performed in your own user transaction to ensure correct operation of your program (script). This transaction must already exist at the moment when you want to create an API object (catalog). The reason is that if you modify an object created in an internal transaction, there is no explicit way to identify this transaction for committing. However, if you are running only a very short, uncomplicated and easily comprehensible code, when working with the catalogs, you can avoid creating a user transaction by getting the internal one that was created automatically together with the catalog (see Getting Transactions).

Transaction stores all operations over the database in a cache. They are not physically saved until you call doCommit that actually commits the changes to the database. Various objects can be assigned to one transaction but one object can naturally be created only using one transaction.

Relations and transactions

A relation must be formed in one transaction, in other words, all objects that take part in the relation must be created using the same transaction to ensure correct operation of your application.

See Also

Working in Transactions

Creating Transactions

Registering Objects to Transactions

Getting Transactions

Committing Transactions

Undoing Changes and Aborting Transactions

Propagating Changes

Calling Workflows on Certain Events