Class Index [+]

Quicksearch

Sequel::JDBC::Transactions

Constants

TRANSACTION_BEGIN
TRANSACTION_COMMIT
TRANSACTION_RELEASE_SP
TRANSACTION_ROLLBACK
TRANSACTION_ROLLBACK_SP
TRANSACTION_SAVEPOINT

Public Instance Methods

supports_savepoints?() click to toggle source

Check the JDBC DatabaseMetaData for savepoint support

    # File lib/sequel/adapters/jdbc/transactions.rb, line 12
12:       def supports_savepoints?
13:         return @supports_savepoints if defined?(@supports_savepoints)
14:         @supports_savepoints = synchronize{|c| c.get_meta_data.supports_savepoints}
15:       end

Private Instance Methods

begin_transaction(conn, opts={}) click to toggle source

Use JDBC connection’s setAutoCommit to false to start transactions

    # File lib/sequel/adapters/jdbc/transactions.rb, line 25
25:       def begin_transaction(conn, opts={})
26:         if supports_savepoints?
27:           th = _trans(conn)
28:           if sps = th[:savepoints]
29:             sps << log_yield(TRANSACTION_SAVEPOINT){conn.set_savepoint}
30:           else
31:             log_yield(TRANSACTION_BEGIN){conn.setAutoCommit(false)}
32:             th[:savepoints] = []
33:           end
34:           th[:savepoint_level] += 1
35:         else
36:           log_yield(TRANSACTION_BEGIN){conn.setAutoCommit(false)}
37:         end
38:       end
commit_transaction(conn, opts={}) click to toggle source

Use JDBC connection’s commit method to commit transactions

    # File lib/sequel/adapters/jdbc/transactions.rb, line 41
41:       def commit_transaction(conn, opts={})
42:         if supports_savepoints?
43:           sps = _trans(conn)[:savepoints]
44:           if sps.empty?
45:             log_yield(TRANSACTION_COMMIT){conn.commit}
46:           elsif supports_releasing_savepoints?
47:             log_yield(TRANSACTION_RELEASE_SP){supports_releasing_savepoints? ? conn.release_savepoint(sps.last) : sps.last}
48:           end
49:         else
50:           log_yield(TRANSACTION_COMMIT){conn.commit}
51:         end
52:       end
remove_transaction(conn, committed) click to toggle source

Use JDBC connection’s setAutoCommit to true to enable non-transactional behavior

    # File lib/sequel/adapters/jdbc/transactions.rb, line 55
55:       def remove_transaction(conn, committed)
56:         if supports_savepoints?
57:           sps = _trans(conn)[:savepoints]
58:           conn.setAutoCommit(true) if sps.empty?
59:           sps.pop
60:         else
61:           conn.setAutoCommit(true)
62:         end
63:       ensure
64:         super
65:       end
rollback_transaction(conn, opts={}) click to toggle source

Use JDBC connection’s rollback method to rollback transactions

    # File lib/sequel/adapters/jdbc/transactions.rb, line 68
68:       def rollback_transaction(conn, opts={})
69:         if supports_savepoints?
70:           sps = _trans(conn)[:savepoints]
71:           if sps.empty?
72:             log_yield(TRANSACTION_ROLLBACK){conn.rollback}
73:           else
74:             log_yield(TRANSACTION_ROLLBACK_SP){conn.rollback(sps.last)}
75:           end
76:         else
77:           log_yield(TRANSACTION_ROLLBACK){conn.rollback}
78:         end
79:       end
supports_releasing_savepoints?() click to toggle source

Most JDBC drivers that support savepoints support releasing them.

    # File lib/sequel/adapters/jdbc/transactions.rb, line 20
20:       def supports_releasing_savepoints?
21:         true
22:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.