Back

with-transaction+options (clj)

(source)

macro

(with-transaction+options [sym transactable opts] & body)
Given a transactable object, assumed to be wrapped with options, gets a connection, rewraps it with those options, and binds it to `sym`, then executes the `body` in that context, committing any changes if the body completes successfully, otherwise rolling back any changes made. Like `with-open`, if `with-transaction+options` creates a new `Connection` object, it will automatically close it for you. Note: the bound `sym` will be a **wrapped** connectable and not a plain Java object, so you cannot call JDBC methods directly on it like you can with `with-transaction`. The options map supports: * `:isolation` -- `:none`, `:read-committed`, `:read-uncommitted`, `:repeatable-read`, `:serializable`, * `:read-only` -- `true` / `false` (`true` will make the `Connection` readonly), * `:rollback-only` -- `true` / `false` (`true` will make the transaction rollback, even if it would otherwise succeed).

Examples