About Commit Cycle Processing

A middle-tier service commits a transaction by using an application module. The flowchart in Figure 1 illustrates the process for the commit cycle.

Figure 1: Flowchart for Commit Cycle Processing

  1. Validate entity objects.

    The Business Components for Java framework walks through the transaction's list and validates the entity objects needing validation. The validation step is performed 10 times (this number can be altered by calling DBTransaction.setValidationThreshold()). If the final attempt at validation fails, the framework throws a JboException and exits.

    Note: Looping gives application developers a chance to set attribute values based on validation logic, then validate these new updates.

    The framework then calls postChanges() on all TransactionPostListeners. If you have overriden postChanges() in an entity object, the method will be called at this stage.

  2. Post entity objects.

    The business components framework posts changes to the database, then calls beforeCommit() on all TransactionListeners.

    The framework performs one final validation on any modified entity objects. If any component is invalidated the framework throws an exception, restores the database to the state it was in before the commit cycle started, and exits. New changes are not allowed at this point in the commit cycle;. any changes are made after this commit cycle is complete, during afterCommit().

  3. Commit changes.

    The framework invokes database commit to commit the transaction, then calls afterCommit() on all TransactionListeners.

    If a JboException is thrown during the commit stage, the framework restores the database to the state it was in before the commit cycle started, throws a new JboException, and exits.

    Note: During the commit cycle, the framework ensures that a listener's method (for example, a particular TransactionListener's beforeCommit() method) is invoked only once.