|
5 | 5 | */
|
6 | 6 | package org.hibernate.reactive.pool.impl;
|
7 | 7 |
|
8 |
| -import io.vertx.sqlclient.PropertyKind; |
| 8 | +import java.sql.ResultSet; |
| 9 | +import java.util.ArrayList; |
| 10 | +import java.util.List; |
| 11 | +import java.util.Objects; |
| 12 | +import java.util.concurrent.CompletionStage; |
| 13 | + |
| 14 | +import org.hibernate.engine.jdbc.internal.FormatStyle; |
| 15 | +import org.hibernate.engine.jdbc.spi.SqlStatementLogger; |
| 16 | +import org.hibernate.reactive.adaptor.impl.ResultSetAdaptor; |
| 17 | +import org.hibernate.reactive.pool.ReactiveConnection; |
| 18 | + |
9 | 19 | import io.vertx.sqlclient.Pool;
|
| 20 | +import io.vertx.sqlclient.PropertyKind; |
10 | 21 | import io.vertx.sqlclient.Row;
|
11 | 22 | import io.vertx.sqlclient.RowIterator;
|
12 | 23 | import io.vertx.sqlclient.RowSet;
|
|
15 | 26 | import io.vertx.sqlclient.SqlResult;
|
16 | 27 | import io.vertx.sqlclient.Transaction;
|
17 | 28 | import io.vertx.sqlclient.Tuple;
|
18 |
| -import org.hibernate.engine.jdbc.internal.FormatStyle; |
19 |
| -import org.hibernate.engine.jdbc.spi.SqlStatementLogger; |
20 |
| -import org.hibernate.reactive.adaptor.impl.ResultSetAdaptor; |
21 |
| -import org.hibernate.reactive.pool.ReactiveConnection; |
22 |
| - |
23 |
| -import java.sql.ResultSet; |
24 |
| -import java.util.ArrayList; |
25 |
| -import java.util.List; |
26 |
| -import java.util.Objects; |
27 |
| -import java.util.concurrent.CompletionStage; |
28 | 29 |
|
29 | 30 | import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;
|
30 | 31 |
|
@@ -194,40 +195,25 @@ private void feedback(String sql) {
|
194 | 195 | }
|
195 | 196 |
|
196 | 197 | private SqlClient client() {
|
197 |
| - return transaction != null ? transaction : connection; |
| 198 | + return connection; |
198 | 199 | }
|
199 | 200 |
|
200 | 201 | @Override
|
201 | 202 | public CompletionStage<Void> beginTransaction() {
|
202 |
| - transaction = connection.begin(); |
203 |
| - return voidFuture(); |
204 |
| -// return execute("begin"); |
| 203 | + return Handlers.<Transaction>toCompletionStage(connection::begin) |
| 204 | + .thenAccept( tx -> transaction = tx ); |
205 | 205 | }
|
206 | 206 |
|
207 | 207 | @Override
|
208 | 208 | public CompletionStage<Void> commitTransaction() {
|
209 |
| - return Handlers.toCompletionStage( |
210 |
| - handler -> transaction.commit( |
211 |
| - ar -> { |
212 |
| - transaction = null; |
213 |
| - handler.handle( ar ); |
214 |
| - } |
215 |
| - ) |
216 |
| - ); |
217 |
| -// return execute("commit"); |
| 209 | + return Handlers.<Void>toCompletionStage(transaction::commit) |
| 210 | + .whenComplete( (v, x) -> transaction = null ); |
218 | 211 | }
|
219 | 212 |
|
220 | 213 | @Override
|
221 | 214 | public CompletionStage<Void> rollbackTransaction() {
|
222 |
| - return Handlers.toCompletionStage( |
223 |
| - handler -> transaction.rollback( |
224 |
| - ar -> { |
225 |
| - transaction = null; |
226 |
| - handler.handle( ar ); |
227 |
| - } |
228 |
| - ) |
229 |
| - ); |
230 |
| -// return execute("rollback"); |
| 215 | + return Handlers.<Void>toCompletionStage(transaction::rollback) |
| 216 | + .whenComplete( (v, x) -> transaction = null ); |
231 | 217 | }
|
232 | 218 |
|
233 | 219 | @Override
|
|
0 commit comments