net.corda.node.utilities / StrandLocalTransactionManager

# StrandLocalTransactionManager

`class StrandLocalTransactionManager`

A relatively close copy of the ThreadLocalTransactionManager in Exposed but with the following adjustments to suit our environment:

Because the construction of a Database instance results in replacing the singleton TransactionManager instance, our tests involving two MockNodes effectively replace the database instances of each other and continue to trample over each other. So here we use a companion object to hold them as ThreadLocal and StrandLocalTransactionManager is otherwise effectively stateless so its replacement does not matter. The ThreadLocal is then set correctly and explicitly just prior to initiating a transaction in databaseTransaction and createDatabaseTransaction above.

The StrandLocalTransactionManager instances have an Observable of the transaction close Boundarys which facilitates the use of Observable.afterDatabaseCommit to create event streams that only emit once the database transaction is closed and the data has been persisted and becomes visible to other observers.

### Types

Boundary | `data class Boundary`

### Constructors

<init> | `StrandLocalTransactionManager(initWithDatabase: <ERROR CLASS>)` A relatively close copy of the ThreadLocalTransactionManager in Exposed but with the following adjustments to suit our environment:

### Functions

currentOrNull | `fun currentOrNull(): <ERROR CLASS>?`
newTransaction | `fun newTransaction(isolation: Int): <ERROR CLASS>`

### Companion Object Properties

database | `var database: <ERROR CLASS>`
manager | `val manager: StrandLocalTransactionManager`
transactionBoundaries | `val transactionBoundaries: <ERROR CLASS><Boundary, Boundary>`
transactionId | `val transactionId: UUID`

### Companion Object Functions

restoreThreadLocalTx | `fun restoreThreadLocalTx(context: <ERROR CLASS><<ERROR CLASS>?, <ERROR CLASS>?>): Unit`
setThreadLocalTx | `fun setThreadLocalTx(tx: <ERROR CLASS>?): <ERROR CLASS><<ERROR CLASS>?, <ERROR CLASS>?>`