Implementation of SQL transaction logic.
In general, you cannot nest transactions. clojure.java.jdbc
would
ignore any attempt to create a nested transaction, even tho' some
databases do support it. next.jdbc
allows you to call with-transaction
even while you are inside an active transaction, but the behavior may
vary across databases and the commit or rollback boundaries may not be
what you expect. In order to avoid two transactions constructed on the
same connection from interfering with each other, next.jdbc
locks on
the Connection
object (this prevents concurrent transactions on separate
threads from interfering but will cause deadlock on a single thread --
so beware).
Consequently, this namespace exposes a dynamic variable, *nested-tx*
,
which can be used to vary the behavior when an attempt is made to start
a transaction when you are already inside a transaction.
Implementation of SQL transaction logic. In general, you cannot nest transactions. `clojure.java.jdbc` would ignore any attempt to create a nested transaction, even tho' some databases do support it. `next.jdbc` allows you to call `with-transaction` even while you are inside an active transaction, but the behavior may vary across databases and the commit or rollback boundaries may not be what you expect. In order to avoid two transactions constructed on the same connection from interfering with each other, `next.jdbc` locks on the `Connection` object (this prevents concurrent transactions on separate threads from interfering but will cause deadlock on a single thread -- so beware). Consequently, this namespace exposes a dynamic variable, `*nested-tx*`, which can be used to vary the behavior when an attempt is made to start a transaction when you are already inside a transaction.
Controls the behavior when a nested transaction is attempted.
Possible values are:
:allow
-- the default: assumes you know what you are doing!:ignore
-- the same behavior as clojure.java.jdbc
: the nested
transaction is simply ignored and any SQL operations inside it are
executed in the context of the outer transaction.:prohibit
-- any attempt to create a nested transaction will throw
an exception: this is the safest but most restrictive approach so
that you can make sure you don't accidentally have any attempts
to create nested transactions (since that might be a bug in your code).Controls the behavior when a nested transaction is attempted. Possible values are: * `:allow` -- the default: assumes you know what you are doing! * `:ignore` -- the same behavior as `clojure.java.jdbc`: the nested transaction is simply ignored and any SQL operations inside it are executed in the context of the outer transaction. * `:prohibit` -- any attempt to create a nested transaction will throw an exception: this is the safest but most restrictive approach so that you can make sure you don't accidentally have any attempts to create nested transactions (since that might be a bug in your code).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close