public 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 class StrandLocalTransactionManager
is otherwise effectively stateless so it's replacement does not matter. The ThreadLocal is then set correctly and
explicitly just prior to initiating a transaction in databaseTransaction and createDatabaseTransaction above.
The class StrandLocalTransactionManager
instances have an Observable of the transaction close class StrandLocalTransactionManager.Boundary
s 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.
Modifier and Type | Class and Description |
---|---|
static class |
StrandLocalTransactionManager.Boundary |
static class |
StrandLocalTransactionManager.Companion |
Modifier and Type | Field and Description |
---|---|
static StrandLocalTransactionManager.Companion |
Companion |
Constructor and Description |
---|
StrandLocalTransactionManager(org.jetbrains.exposed.sql.Database initWithDatabase)
A relatively close copy of the ThreadLocalTransactionManager in Exposed but with the following adjustments to suit
our environment:
|
Modifier and Type | Method and Description |
---|---|
org.jetbrains.exposed.sql.Transaction |
currentOrNull() |
org.jetbrains.exposed.sql.Transaction |
newTransaction(int isolation) |
public static StrandLocalTransactionManager.Companion Companion
public StrandLocalTransactionManager(org.jetbrains.exposed.sql.Database initWithDatabase)
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 class StrandLocalTransactionManager
is otherwise effectively stateless so it's replacement does not matter. The ThreadLocal is then set correctly and
explicitly just prior to initiating a transaction in databaseTransaction and createDatabaseTransaction above.
The class StrandLocalTransactionManager
instances have an Observable of the transaction close class StrandLocalTransactionManager.Boundary
s 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.