commitTransaction Instruction

The commitTransaction instruction commits changes made within a transaction to persistent storage.

Syntax

The syntax of the commitTransaction instruction is:

commitTransaction;

Description

Persistent transactions update persistent objects only. (Use the commitTransientTransaction instruction to update transient objects.)

The commitTransaction instruction requests the JADE Object Manager to make permanent the changes that were made to persistent objects after a beginTransaction instruction; that is, to commit them to physical storage on a database server. It also causes locks to be released for objects that were updated within the transaction.

To avoid having to specify commitTransaction; in full, you can simply press the Ctrl+Shift+C keys at the position in the method at which the instruction is to be inserted.

Executing the commitTransaction instruction is prohibited in the current process when the prohibited parameter in the Process class prohibitPersistentUpdates method is set to true.

For details about reading and writing transactions, see "Using Read and Write Transactions", earlier in this chapter and for details about the restrictions that apply to transactions when using the serverExecution or clientExecution method option, see "Server and Client Execution Restrictions", earlier in this chapter.

Example

The following example shows the use of the commitTransaction instruction in a method on Employee class that is used to update employee details.

updateDetails(address:     String;
              phone:       String;
              dateOfBirth: Date) updating;
begin
    beginTransaction;
    homeAddress := address;
    homePhone   := phone;
    birthDate   := dateOfBirth;
    commitTransaction;
end;