OctaviusClientImpl

internal class OctaviusClientImpl(provider: SessionProvider, onClose: () -> Unit? = null, dynamicJson: Json = octaviusJson, dynamicWriteStrategy: DynamicWriteStrategy = DynamicWriteStrategy.AUTOMATIC_WHEN_UNAMBIGUOUS) : OctaviusClient

The only implementation of OctaviusClient, doing everything through its SessionProvider.

Parameters

onClose

What close releases, or null where the client owns nothing.

Constructors

Link copied to clipboard
constructor(provider: SessionProvider, onClose: () -> Unit? = null, dynamicJson: Json = octaviusJson, dynamicWriteStrategy: DynamicWriteStrategy = DynamicWriteStrategy.AUTOMATIC_WHEN_UNAMBIGUOUS)

Properties

Link copied to clipboard
open override val dynamicTypes: DynamicTypes

The dynamic_dto types this client knows. Nothing reaches the database until a type is registered.

Functions

Link copied to clipboard
open override fun close()

Releases what this client holds. A data source it was given rather than built is not closed.

Link copied to clipboard
open override fun deleteFrom(table: String): DeleteQuery

Starts a DELETE from table, which renders only with a WHERE.

Link copied to clipboard
open override fun <T> execute(block: OctaviusSessionOperations.() -> T): T

Runs block on a session: inside a transaction on this thread the transaction's, otherwise one borrowed for this call, whose statements commit as they go.

Link copied to clipboard
open fun executeTransactionPlan(plan: TransactionPlan, propagation: TransactionPropagation = TransactionPropagation.REQUIRED, isolation: TransactionIsolationLevel? = null, readOnly: Boolean = false, statementTimeout: Duration? = null, transactionTimeout: Duration? = null): TransactionPlanResult

Runs every step of plan in one transaction, in order, and returns what each produced. A step's TransactionValues are resolved just before it runs.

Link copied to clipboard
open override fun insertInto(table: String): InsertQuery

Starts an INSERT into table.

Link copied to clipboard
open override fun rawQuery(sql: String): RawQuery

SQL written by hand, with @name parameters. Every terminal call runs it, so calling two runs it twice.

Link copied to clipboard
open override fun select(vararg columns: String): SelectQuery

Starts a SELECT of columns, each passed through as SQL: "id", "count(*) AS total".

Link copied to clipboard
open override fun <T> transaction(propagation: TransactionPropagation = TransactionPropagation.REQUIRED, isolation: TransactionIsolationLevel? = null, readOnly: Boolean = false, statementTimeout: Duration? = null, transactionTimeout: Duration? = null, block: OctaviusClient.() -> T): T

Runs block in a transaction, committing when it returns and rolling back when it throws. The receiver offers no commit or rollback of its own.

Link copied to clipboard
open fun <T> transactionResult(propagation: TransactionPropagation = TransactionPropagation.REQUIRED, isolation: TransactionIsolationLevel? = null, readOnly: Boolean = false, statementTimeout: Duration? = null, transactionTimeout: Duration? = null, block: OctaviusClient.() -> DataResult<T>): DataResult<T>

transaction for the result style. A plain transaction rolls back only on a throw, so a failure turned into a value inside it is committed over; here a returned DataResult.Failure rolls back.

Link copied to clipboard
open override fun update(table: String): UpdateQuery

Starts an UPDATE of table, which renders only with a WHERE.