0

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?

2 Answers 2

2

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.

Transaction

0

As per my understanding, a single log record is created for each transaction unit. for the above answer, there would two log records.

Please correct me if I am wrong.

1
  • 1
    Does "single log record" refer to a line in an Apex Log? One transaction can certainly have thousands of log records in that sense. Or does "single log record" refer to one instance of an ApexLog? Feb 3 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .