Class: VertxSqlClient::Transaction

Inherits:
SqlClient
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb

Overview

A transaction that allows to control the transaction and receive events.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 24

def @@j_api_type.accept?(obj)
  obj.class == Transaction
end

+ (Object) j_api_type


33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 33

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


36
37
38
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 36

def self.j_class
  Java::IoVertxSqlclient::Transaction.java_class
end

+ (Object) unwrap(obj)


30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 30

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 27

def @@j_api_type.wrap(obj)
  Transaction.new(obj)
end

Instance Method Details

- (self) abort_handler { ... }

Set an handler to be called when the transaction is aborted.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 94

def abort_handler
  if block_given?
    @j_del.java_method(:abortHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling abort_handler()"
end

- (void) close

This method returns an undefined value.

Rollback the transaction and release the associated resources.

Raises:

  • (ArgumentError)

103
104
105
106
107
108
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 103

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (void) commit { ... }

This method returns an undefined value.

Like #commit with an handler to be notified when the transaction commit has completed

Yields:

Raises:

  • (ArgumentError)

72
73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 72

def commit
  if !block_given?
    return @j_del.java_method(:commit, []).call()
  elsif block_given?
    return @j_del.java_method(:commit, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling commit()"
end

- (self) prepare(sql = nil) { ... }

Create a prepared query.

Parameters:

  • sql (String) (defaults to: nil)
    the sql

Yields:

  • the handler notified with the prepared query asynchronously

Returns:

  • (self)

Raises:

  • (ArgumentError)

62
63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 62

def prepare(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:prepare, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::PreparedStatement) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepare(#{sql})"
end

- (::VertxSqlClient::PreparedQuery) prepared_query(sql = nil)

Create a prepared query, one of the Query#execute or PreparedQuery#execute_batch methods must be called to execute the query.

Parameters:

  • sql (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)

52
53
54
55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 52

def prepared_query(sql=nil)
  if sql.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::PreparedQuery,::VertxSqlClient::RowSet.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql})"
end

- (::VertxSqlClient::Query) query(sql = nil)

Create a query, the Query#execute method must be called to execute the query.

Parameters:

  • sql (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)

42
43
44
45
46
47
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 42

def query(sql=nil)
  if sql.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:query, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::Query,::VertxSqlClient::RowSet.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end

- (void) rollback { ... }

This method returns an undefined value.

Like #rollback with an handler to be notified when the transaction rollback has completed

Yields:

Raises:

  • (ArgumentError)

83
84
85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/transaction.rb', line 83

def rollback
  if !block_given?
    return @j_del.java_method(:rollback, []).call()
  elsif block_given?
    return @j_del.java_method(:rollback, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling rollback()"
end