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)
}
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.

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.

Implementation

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