Liking cljdoc? Tell your friends :D

jdbc.transaction

Transactions support for clojure.jdbc

WARNING: This namespace is deprecated and will be removed in clojure.jdbc 0.6.0.

Transactions support for clojure.jdbc

WARNING: This namespace is deprecated and will be removed in
clojure.jdbc 0.6.0.
raw docstring

*default-tx-strategy*clj

Default transaction strategy implementation.

Default transaction strategy implementation.
sourceraw docstring

begin!clj

source

call-in-transactionclj

(call-in-transaction
  conn
  func
  &
  [{:keys [savepoints strategy] :or {savepoints true} :as opts}])

Wrap function in one transaction. This function accepts as a parameter a transaction strategy. If no one is specified, DefaultTransactionStrategy is used.

With DefaultTransactionStrategy, if current connection is already in transaction, it uses truly nested transactions for properly handle it. The availability of this feature depends on database support for it.

Example:

(with-connection dbspec conn (call-in-transaction conn (fn [conn] (execute! conn 'DROP TABLE foo;'))))

For more idiomatic code, you should use with-transaction macro.

Depending on transaction strategy you are using, this function can accept additional parameters. The default transaction strategy exposes two additional parameters:

  • :isolation-level - set isolation level for this transaction
  • :read-only - set current transaction to read only
Wrap function in one transaction.
This function accepts as a parameter a transaction strategy. If no one
is specified, `DefaultTransactionStrategy` is used.

With `DefaultTransactionStrategy`, if current connection is already in
transaction, it uses truly nested transactions for properly handle it.
The availability of this feature depends on database support for it.

Example:

(with-connection dbspec conn
  (call-in-transaction conn (fn [conn] (execute! conn 'DROP TABLE foo;'))))

For more idiomatic code, you should use `with-transaction` macro.

Depending on transaction strategy you are using, this function can accept
additional parameters. The default transaction strategy exposes two additional
parameters:

- `:isolation-level` - set isolation level for this transaction
- `:read-only` - set current transaction to read only
sourceraw docstring

commit!clj

source

is-rollback-set?clj

(is-rollback-set? conn)

Check if a current connection in one transaction is marked for rollback.

This should be used in one transaction, in other case this function always return false.

Check if a current connection in one transaction
is marked for rollback.

This should be used in one transaction, in other case this
function always return false.
sourceraw docstring

ITransactionStrategycljprotocol

source

rollback!clj

source

set-rollback!clj

(set-rollback! conn)

Mark a current connection for rollback.

It ensures that on the end of the current transaction instead of commit changes, rollback them.

This function should be used inside of a transaction block, otherwise this function does nothing.

Example:

(with-transaction conn (make-some-queries-without-changes conn) (set-rollback! conn))

Mark a current connection for rollback.

It ensures that on the end of the current transaction
instead of commit changes, rollback them.

This function should be used inside of a transaction
block, otherwise this function does nothing.

Example:

(with-transaction conn
  (make-some-queries-without-changes conn)
  (set-rollback! conn))
sourceraw docstring

unset-rollback!clj

(unset-rollback! conn)

Revert flag setted by set-rollback! function. This function should be used inside of a transaction block, otherwise this function does nothing.

Revert flag setted by `set-rollback!` function.
This function should be used inside of a transaction
block, otherwise this function does nothing.
sourceraw docstring

with-transactioncljmacro

(with-transaction conn & body)

Creates a context that evaluates in transaction (or nested transaction). This is a more idiomatic way to execute some database operations in atomic way.

Example:

(with-transaction conn (execute! conn 'DROP TABLE foo;') (execute! conn 'DROP TABLE bar;'))

Also, you can pass additional options to transaction:

(with-transaction conn {:read-only true} (execute! conn 'DROP TABLE foo;') (execute! conn 'DROP TABLE bar;'))

Creates a context that evaluates in transaction (or nested transaction).
This is a more idiomatic way to execute some database operations in
atomic way.

Example:

(with-transaction conn
  (execute! conn 'DROP TABLE foo;')
  (execute! conn 'DROP TABLE bar;'))

Also, you can pass additional options to transaction:

(with-transaction conn {:read-only true}
  (execute! conn 'DROP TABLE foo;')
  (execute! conn 'DROP TABLE bar;'))
sourceraw docstring

with-transaction-strategycljmacro

(with-transaction-strategy conn strategy & body)

Set some transaction strategy connection in the current context scope. This method not uses thread-local dynamic variables and connection preserves a transaction strategy throught threads.

Set some transaction strategy connection in the current context scope.
This method not uses thread-local dynamic variables and connection
preserves a transaction strategy throught threads.
sourceraw docstring

wrap-transaction-strategyclj

(wrap-transaction-strategy conn strategy)

Simple helper function that associate a strategy to a connection and return a new connection object with wrapped stragy.

Example:

(let [conn (wrap-transaction-strategy simplecon (MyStrategy.))] (use-your-new-conn conn))

Simple helper function that associate a strategy
to a connection and return a new connection object
with wrapped stragy.

Example:

(let [conn (wrap-transaction-strategy simplecon (MyStrategy.))]
  (use-your-new-conn conn))
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close