OctaviusClient
Hands out queries and sessions, and runs transactions over them. That is all it is.
A query taken from here - rawQuery, select, insertInto, update, deleteFrom - is a RunnableQuery, which carries the terminal family and finds its own session when one of them is called. Nothing has to be opened around it, which is what keeps a single query to a single expression.
Where the work is not a query - copy, largeObjects, notifications, or several statements that have to share one session - execute hands over the driver's own OctaviusSessionOperations and gets out of the way. Neither path wraps or renames anything the driver named.
val db = OctaviusClient.fromDataSource(hikariDataSource)
val senators = db.rawQuery("SELECT id, cognomen FROM senators WHERE province_id = @p")
.fetchObjects<Senator>("p" to 7)What it buys over calling dataSource.getOctaviusSession() by hand is the thing a data layer of any size ends up needing: a repository function can open a scope without knowing whether it is already inside a transaction, and be right either way. A session opened here joins the transaction running on this thread if there is one, so the same function works standalone and as a step in a larger unit of work, without a session in its signature.
Failures arrive as exceptions, which is what the driver raises and what a try/catch expects. Where a failure should be a value instead, the result style has a door for each width: asResult for one query, transactionResult for a transaction, and dbResult for anything else.
Inheritors
Properties
Functions
Starts building a DELETE from the given table. A WHERE is required before it will render.
Runs every step of plan in one transaction, in the order they were added, and returns what each produced.
Starts building an INSERT into the given table.
Starts building a SELECT over the given columns.
Runs block inside a transaction, committing when it returns and rolling back when it throws.
Runs block in a transaction that understands a returned failure, and hands back what it produced.
Starts building an UPDATE of the given table. A WHERE is required before it will render.