TransactionPlan
class TransactionPlan
Operations to run as one transaction, assembled before any of it runs - for a sequence decided in one place and run in another. Where the sequence is written out where it runs, a transaction { } block is simpler.
Steps run in the order they were added, and a step uses what an earlier one produced through the StepHandle returned:
val plan = TransactionPlan()
val edictId = plan.add(
db.insertInto("edicts").values(edict).returning("id")
.asStep().fetchFieldStrict<Int>(edict)
)
for (item in levy) {
plan.add(
db.insertInto("edict_items").values(listOf("edict_id", "province_id", "amount"))
.asStep().executeUpdate(
"edict_id" to edictId.value(),
"province_id" to item.provinceId,
"amount" to item.amount
)
)
}
val results = db.executeTransactionPlan(plan)Content copied to clipboard
Running a plan does not change it, so retrying a serialization failure is a loop around executeTransactionPlan, each run resolving its handles against its own results.
Types
Link copied to clipboard
internal class PlannedStep(val handle: StepHandle<*>, val query: RunnableQuery<*>, val params: Map<String, Any?>, val run: (Map<String, Any?>) -> Any?)
A step and the handle it was filed under.
Functions
Link copied to clipboard
Appends step, built with RunnableQuery.asStep, and returns the handle later steps refer to it by.
Link copied to clipboard