Working with Objects in TransactionsWe can distinguish two different types of transactions:
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. | |||||