SessionProvider

Answers the only question the client cannot answer for itself: which session does this operation run on.

The client is a pooled facade over a driver that is session-per-connection, and this interface is where those two meet. Everything above it - queries, builders, transaction plans - is written against execute and never obtains a session of its own, which is what lets the same query code run standalone on a connection pool and under a transaction manager that owns the connection itself.

Implementations decide what "the current session" means. The default one binds it to the thread; one backed by Spring finds it on whatever the surrounding @Transactional bound.

Inheritors

Functions

Link copied to clipboard
open override fun close()

Releases what this provider holds of its own. Whatever supplies its connections is not its to close.

Link copied to clipboard
abstract fun <T> execute(action: OctaviusSessionOperations.() -> T): T

Runs action on the session for the current context.

Link copied to clipboard
abstract fun <T> transaction(definition: TransactionDefinition, block: () -> T): T

Runs block with a transaction open, committing when it returns and rolling back when it throws.