module ArJdbc::Abstract::TransactionSupport

Provides the basic interface needed to support transactions for JDBC based adapters

Public Instance Methods

begin_db_transaction() click to toggle source

Starts a database transaction. @override

# File lib/arjdbc/abstract/transaction_support.rb, line 31
def begin_db_transaction
  log('BEGIN TRANSACTION'.freeze, nil) { @connection.begin }
end
begin_isolated_db_transaction(isolation) click to toggle source

Starts a database transaction. @param isolation the transaction isolation to use

# File lib/arjdbc/abstract/transaction_support.rb, line 37
def begin_isolated_db_transaction(isolation)
  log("BEGIN ISOLATED TRANSACTION - #{isolation}", nil) { @connection.begin(isolation) }
end
commit_db_transaction() click to toggle source

Commits the current database transaction. @override

# File lib/arjdbc/abstract/transaction_support.rb, line 43
def commit_db_transaction
  log('COMMIT TRANSACTION'.freeze, nil) { @connection.commit }
end
create_savepoint(name = current_savepoint_name) click to toggle source

Creates a (transactional) save-point one can rollback to. Unlike 'plain' `ActiveRecord` it is allowed to pass a save-point name. @param name the save-point name @return save-point name (even if nil passed will be generated) @since 1.3.0 @extension added optional name parameter

# File lib/arjdbc/abstract/transaction_support.rb, line 62
def create_savepoint(name = current_savepoint_name)
  log("SAVEPOINT #{name}", 'Savepoint') { @connection.create_savepoint(name) }
end
exec_rollback_db_transaction() click to toggle source

Rolls back the current database transaction. Called from 'rollback_db_transaction' in the AbstractAdapter @override

# File lib/arjdbc/abstract/transaction_support.rb, line 50
def exec_rollback_db_transaction
  log('ROLLBACK TRANSACTION'.freeze, nil) { @connection.rollback }
end
exec_rollback_to_savepoint(name = current_savepoint_name) click to toggle source

Transaction rollback to a given (previously created) save-point. If no save-point name given rollback to the last created one. Called from 'rollback_to_savepoint' in AbstractAdapter @param name the save-point name @extension added optional name parameter

# File lib/arjdbc/abstract/transaction_support.rb, line 71
def exec_rollback_to_savepoint(name = current_savepoint_name)
  log("ROLLBACK TO SAVEPOINT #{name}", 'Savepoint') { @connection.rollback_savepoint(name) }
end
release_savepoint(name = current_savepoint_name) click to toggle source

Release a previously created save-point. @note Save-points are auto-released with the transaction they're created in (on transaction commit or roll-back). @param name the save-point name @extension added optional name parameter

# File lib/arjdbc/abstract/transaction_support.rb, line 80
def release_savepoint(name = current_savepoint_name)
  log("RELEASE SAVEPOINT #{name}", 'Savepoint') { @connection.release_savepoint(name) }
end
supports_savepoints?() click to toggle source

Does our database (+ its JDBC driver) support save-points? @since 1.3.0 @override

# File lib/arjdbc/abstract/transaction_support.rb, line 12
def supports_savepoints?
  @connection.supports_savepoints?
end
supports_transaction_isolation?(level = nil) click to toggle source

Does this adapter support setting the isolation level for a transaction? Unlike 'plain' `ActiveRecord` we allow checking for concrete transaction isolation level support by the database. @param level optional to check if we support a specific isolation level @since 1.3.0 @extension added optional level parameter

# File lib/arjdbc/abstract/transaction_support.rb, line 22
def supports_transaction_isolation?(level = nil)
  return false unless level
  @connection.supports_transaction_isolation?(level)
end