OctaviusJdbcTransactionManager

open class OctaviusJdbcTransactionManager(val dataSource: DataSource) : AbstractPlatformTransactionManager, ResourceTransactionManager

A transaction manager for a DataSource that runs each transaction through an OctaviusSession, so a failure of the database or the connection leaves it as the driver's own exception.

The session is opened when the transaction begins and closed when it ends, and every OctaviusTemplate.execute inside the transaction runs through it.

On a connection that is already gone a commit raises and a rollback stays quiet; so do releasing a Propagation.NESTED savepoint and rolling back to it.

A commit that raises is rolled back after, whatever rollbackOnCommitFailure says - that setting covers a TransactionException only - so synchronizations hear STATUS_ROLLED_BACK, even where the connection went while the COMMIT waited and the server may have committed.

@Transactional(timeout = ...) is enforced on the server, as timeoutScope names.

OctaviusSpringAutoConfiguration registers it when the application declares no transaction manager of its own.

Constructors

Link copied to clipboard
constructor(dataSource: DataSource)

Properties

Link copied to clipboard

The data source whose connections the transactions run on.

Link copied to clipboard
Link copied to clipboard
protected var logger: Log?
Link copied to clipboard
open override val resourceFactory: Any
Link copied to clipboard

What a transaction's timeout is enforced on, TransactionTimeoutScope.STATEMENT unless set. A transaction without a timeout - none on the annotation, no defaultTimeout here - sends nothing.

Link copied to clipboard
var transactionExecutionListeners: Collection<TransactionExecutionListener?>?

Functions

Link copied to clipboard
open fun addListener(listener: TransactionExecutionListener?)
Link copied to clipboard
fun commit(status: TransactionStatus?)
Link copied to clipboard
protected open fun determineTimeout(definition: TransactionDefinition?): Int
Link copied to clipboard
protected open override fun doBegin(transaction: Any, definition: TransactionDefinition)

Takes a connection, opens the session over it, begins the transaction, and binds the session to the thread. A connection the data source would not hand over comes out as the driver's exception, as from OctaviusTemplate, not as Spring's CannotCreateTransactionException.

Link copied to clipboard
protected open override fun doCleanupAfterCompletion(transaction: Any)
Link copied to clipboard
protected open override fun doCommit(status: DefaultTransactionStatus)

Commits, or raises NetworkException(CONNECTION_ABORTED) for a transaction whose connection is already gone.

Link copied to clipboard
protected open override fun doGetTransaction(): Any

Picks up the session of a transaction this manager is running; one OctaviusTemplate bound is not one.

Link copied to clipboard
protected open override fun doResume(transaction: Any?, suspendedResources: Any)
Link copied to clipboard
protected open override fun doRollback(status: DefaultTransactionStatus)

Rolls back, and stays quiet for a transaction whose connection is already gone.

Link copied to clipboard
protected open override fun doSetRollbackOnly(status: DefaultTransactionStatus)
Link copied to clipboard
protected open override fun doSuspend(transaction: Any): Any
Link copied to clipboard
open override fun getResourceFactory(): Any
Link copied to clipboard
fun getTransaction(definition: @Nullable TransactionDefinition?): TransactionStatus?
Link copied to clipboard
protected fun invokeAfterCompletion(synchronizations: List<TransactionSynchronization?>?, completionStatus: Int)
Link copied to clipboard
protected open override fun isExistingTransaction(transaction: Any): Boolean
Link copied to clipboard
protected open fun prepareForCommit(status: DefaultTransactionStatus?)
Link copied to clipboard
protected open fun prepareSynchronization(status: DefaultTransactionStatus?, definition: TransactionDefinition?)
Link copied to clipboard
protected open fun prepareTransactionalSession(session: OctaviusSession, definition: TransactionDefinition)

Sends the transaction's timeout, where it has one, as SET LOCAL of the setting timeoutScope names, so nothing follows the connection back to the pool. Called only for a transaction this manager begins, never for one a method joins or a savepoint. A statement sent here also sends the transaction's BEGIN, which the driver otherwise holds back until the method's first statement.

protected open fun registerAfterCompletionWithExistingTransaction(transaction: Any?, synchronizations: List<TransactionSynchronization?>?)
Link copied to clipboard
protected fun resume(transaction: @Nullable Any?, resourcesHolder: @Nullable AbstractPlatformTransactionManager.SuspendedResourcesHolder?)
Link copied to clipboard
fun rollback(status: TransactionStatus?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
protected fun suspend(transaction: @Nullable Any?): @Nullable AbstractPlatformTransactionManager.SuspendedResourcesHolder?
Link copied to clipboard
protected fun triggerBeforeCommit(status: DefaultTransactionStatus?)
Link copied to clipboard
protected fun triggerBeforeCompletion(status: DefaultTransactionStatus?)
Link copied to clipboard