In Apex Developer Guide, I found

An Apex transaction represents a set of operations that are executed as a single unit.

My question is, how can I define the set of operations ? That is,

If I have a method init() which called several methods inside it, I can assume that all the operations for calling init() resides in that set of operation i.e. it will be an apex transaction.

So, each entry point is an apex transaction?


Here is an example of a transaction which represents set of operations are executed as a single unit. All DML operations in a transaction either complete successfully, or if an error occurs in one operation, the entire transaction is rolled back and no data is committed to the database.

In this picture, I have tried to show, first transaction is initiated from a button click event, which in turn calls controller method, which again calls Service class's method and finally commits the data in Database.

The second transaction is initiated when Service class's method calls @future method which is asynchronously processed and it creates a separate transaction.

So, in a single transaction, all the methods or operations are part of that same transaction.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.