JdbcTransactor

zio.blocks.sql.JdbcTransactor
See theJdbcTransactor companion object
class JdbcTransactor(connectionFactory: () => Connection, val dialect: SqlDialect, val sqlLogger: SqlLogger = ...) extends Transactor

Attributes

Companion
object
Source
JdbcTransactor.scala
Graph
Supertypes
trait Transactor
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def connect[A](f: DbCon ?=> A): A

Opens a connection, executes f, and closes the connection on return.

Opens a connection, executes f, and closes the connection on return.

Attributes

Source
JdbcTransactor.scala
override def transact[A](isolation: TransactionIsolation, readOnly: Boolean)(f: DbTx ?=> A): A

Opens a connection, applies the requested isolation level and read-only flag, disables auto-commit, executes f, commits on success, and rolls back on exception. Previous autoCommit, isolation level and readOnly flag are restored and the connection is closed after commit or rollback.

Opens a connection, applies the requested isolation level and read-only flag, disables auto-commit, executes f, commits on success, and rolls back on exception. Previous autoCommit, isolation level and readOnly flag are restored and the connection is closed after commit or rollback.

For SqlDialect.SQLite, transact runs with busy_timeout=5000 and IMMEDIATE — fromUrl and sqlite create SQLite connections with busy_timeout=5000 and transaction_mode=IMMEDIATE, and transact also configures any SQLite Connection (including pooled/wrapped via isWrapperFor/unwrap) per-transaction so queue workers reserve the write lock before the SELECT and wait on contention instead of failing the later DELETE with SQLITE_BUSY. See PR #1534 discussion_r3863454094; SQLite is single-consumer.

SQLite note: SQLite natively supports only SERIALIZABLE (its default). Other levels are accepted and applied via Connection.setTransactionIsolation so behaviour is uniform across dialects, but on SQLite the engine still behaves as serializable — the requested level may be ignored by the engine even though it is set on the connection.

Attributes

Definition Classes
Source
JdbcTransactor.scala
override def transact[A](f: DbTx ?=> A): A

Opens a connection, disables auto-commit, executes f, commits on success, and rolls back on exception. The connection is closed after commit or rollback. Preserves the driver's default isolation level and readOnly flag — does not force SERIALIZABLE — so callers that previously relied on the driver default (e.g. PostgreSQL READ_COMMITTED) are not unexpectedly upgraded. Use the two-arg overload to request a specific isolation level.

Opens a connection, disables auto-commit, executes f, commits on success, and rolls back on exception. The connection is closed after commit or rollback. Preserves the driver's default isolation level and readOnly flag — does not force SERIALIZABLE — so callers that previously relied on the driver default (e.g. PostgreSQL READ_COMMITTED) are not unexpectedly upgraded. Use the two-arg overload to request a specific isolation level.

For SqlDialect.SQLite, transact runs with busy_timeout=5000 and IMMEDIATE — fromUrl and sqlite create SQLite connections with busy_timeout=5000 and transaction_mode=IMMEDIATE, and transact also configures any SQLite Connection (including pooled/wrapped via isWrapperFor/unwrap) per-transaction so queue workers reserve the write lock before the SELECT and wait on contention instead of failing the later DELETE with SQLITE_BUSY. See PR #1534 discussion_r3863454094; SQLite is single-consumer.

Attributes

Definition Classes
Source
JdbcTransactor.scala

Concrete fields

Attributes

Source
JdbcTransactor.scala

Attributes

Source
JdbcTransactor.scala