Reference‎ > ‎

Rules: Commit Constraint


A Commit Constraint is defined by a method with the @Constraint annotation:

import com.autobizlogic.abl.businesslogic.annotations.*;
import com.autobizlogic.abl.businesslogicengine.ConstraintFailure;

public class CustomerLogic {

    private Customer customer;
    public void myConstraint() {
        if (customer.getBalance() > 1000)
           ConstraintFailure.failConstraint("Customer " + customer.getName() + 
                " needs to spend less.");

A Commit Constraint is exactly like a Constraint, with the following difference:

A Commit Constraint is only invoked once during a transaction, right before commit. It is therefore possible for a Commit Constraint to be temporary violated in the course of a transaction, so long as it is no longer violated by the end of the transaction. This can be useful in some specialized cases.