Feature Overview
This feature generates transactional methods that roll back when an exception is thrown.
This feature generates transactional methods that roll back when an exception is thrown.
None
public class TransactionDemo {
@transaction
public void init() {
// TODO
}
@transaction
public static Integer sum() {
return 0;
}
}
public class TransactionDemo {
public void init() {
Savepoint sp = Database.setSavepoint();
try {
transaction_init();
}
catch(Exception e) {
Database.rollback(sp);
throw e;
}
}
public static Integer sum() {
Savepoint sp = Database.setSavepoint();
try {
return transaction_sum();
}
catch(Exception e) {
Database.rollback(sp);
throw e;
}
}
private void transaction_init() {
// TODO
}
private static Integer transaction_sum() {
return 0;
}
}
@transaction
will surround the original method with try-catch block so that it will roll back the transaction in case of exceptions.
Contribute on Github! Edit this section.