Package lumis.portal.transaction

The portal transaction framework. Provides and manages transactions for persistence access.

The PortalTransactionFactory provides methods for obtaining ITransaction instances. Use PortalTransactionFactory.createTransaction(boolean) for creating new transactions. The boolean parameter indicates if the created transaction will be associated with the current thread as the current active transaction. The current active transaction in a thread is returned by PortalTransactionFactory.getCurrentTransaction().

The the current transaction management is done by a stack associated with the current thread. When an active transaction ends (by executing its close method), the previously active transaction (next transaction in the stack) becomes the current transaction for the thread.

The recommended code pattern for creating a new transaction is one of the following:

  • try-with-resources pattern:
     try (ITransaction transaction = PortalTransactionFactory.createTransaction())
     {
            transaction.begin();
     
            // execute transactional operations
     
            transaction.commit();
     }
     
  • try-finally pattern:
     ITransaction transaction = PortalTransactionFactory.createTransaction(); // create transaction object
     try
     {
            transaction.begin();
     
            // execute transactional operations
     
            transaction.commit();
     }
     finally
     {
            transaction.close(); // automatically rolls back if commit was not executed
     }
     
Since:
4.2.0
Version:
$Revision: 16888 $ $Date: 2015-02-06 11:17:39 -0200 (Fri, 06 Feb 2015) $