diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/SqlConnection.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/SqlConnection.java index 27c86ab4f..a61f3dd1b 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/SqlConnection.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/SqlConnection.java @@ -68,7 +68,7 @@ public interface SqlConnection extends SqlClient { * Begin a transaction and returns a {@link Transaction} for controlling and tracking * this transaction. *

- * When the connection is explicitely closed, any inflight transaction is rollbacked. + * When the connection is explicitely closed, any inflight transaction is rolled back. */ void begin(Handler> handler); @@ -77,6 +77,13 @@ public interface SqlConnection extends SqlClient { */ Future begin(); + /** + * If @{link {@link #begin()} or {#link {@link #begin(Handler)} has been called, returns + * the associated transaction. Returns null otherwise. + * @return the current associated transaction, or null. + */ + Transaction currentTransaction(); + /** * @return whether the connection uses SSL */ diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java index c2f44d6a2..a8c4081a4 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java @@ -54,6 +54,11 @@ public void handleClosed() { } } + @Override + public Transaction currentTransaction() { + return tx; + } + @Override public void schedule(CommandBase cmd, Promise promise) { if (tx != null) {