TransactionService (interface)

Provides utilities to access active transactions associated with the current thread.

This is a low-level service that domain objects will typically have little need to leverage; there will normally be a transaction started already by the framework at the beginning of an org.apache.isis.applib.services.iactn.Interaction and committed at the end. On occasion though it can be useful to take explicit control over transaction boundaries, which is where the methods provided by this domain service can be useful.

API

TransactionService.java
interface TransactionService {
  Optional<TransactionId> currentTransactionId()     (1)
  TransactionState currentTransactionState()     (2)
  void flushTransaction()     (3)
  void nextTransaction()     (4)
}
1 currentTransactionId()

Optionally returns the unique identifier of the current thread’s transaction, based on whether there is an active transaction associated with the current thread.

2 currentTransactionState()

Returns the state of the current thread’s transaction., or returns TransactionState#NONE , if there is no active transaction associated with the current thread.

3 flushTransaction()

Flushes all changes to the object store.

4 nextTransaction()

Commits the current thread’s transaction (if there is one), and in any case begins a new one.

Members

currentTransactionId()

Optionally returns the unique identifier of the current thread’s transaction, based on whether there is an active transaction associated with the current thread.

currentTransactionState()

Returns the state of the current thread’s transaction., or returns TransactionState#NONE , if there is no active transaction associated with the current thread.

flushTransaction()

Flushes all changes to the object store.

Occasionally useful to ensure that newly persisted domain objects are flushed to the database prior to a subsequent repository query.

If there is no active transaction associated with the current thread, then does nothing.

nextTransaction()

Commits the current thread’s transaction (if there is one), and in any case begins a new one.

Implementation

The core framework provides a default implementation of this service, o.a.i.core.runtimeservices.transaction.TransactionServiceSpring.