|
17 | 17 | import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
18 | 18 | import org.hibernate.query.spi.QueryOptions;
|
19 | 19 | import org.hibernate.reactive.adaptor.impl.PreparedStatementAdaptor;
|
| 20 | +import org.hibernate.reactive.engine.spi.ReactiveSharedSessionContractImplementor; |
20 | 21 | import org.hibernate.reactive.logging.impl.Log;
|
21 | 22 | import org.hibernate.reactive.logging.impl.LoggerFactory;
|
22 | 23 | import org.hibernate.reactive.pool.ReactiveConnection;
|
@@ -48,30 +49,34 @@ public CompletionStage<Integer> executeReactive(
|
48 | 49 | Function<String, PreparedStatement> statementCreator,
|
49 | 50 | BiConsumer<Integer, PreparedStatement> expectationCheck,
|
50 | 51 | ExecutionContext executionContext) {
|
51 |
| - final SharedSessionContractImplementor session = executionContext.getSession(); |
52 |
| - session.autoFlushIfRequired( jdbcMutation.getAffectedTableNames() ); |
53 |
| - |
54 |
| - final LogicalConnectionImplementor logicalConnection = session |
55 |
| - .getJdbcCoordinator() |
56 |
| - .getLogicalConnection(); |
57 |
| - |
58 |
| - final JdbcServices jdbcServices = session.getJdbcServices(); |
59 |
| - final QueryOptions queryOptions = executionContext.getQueryOptions(); |
60 |
| - final String finalSql = finalSql( jdbcMutation, executionContext, jdbcServices, queryOptions ); |
61 |
| - |
62 |
| - Object[] parameters = PreparedStatementAdaptor |
63 |
| - .bind( statement -> prepareStatement( jdbcMutation, statement, jdbcParameterBindings, executionContext ) ); |
64 |
| - |
65 |
| - session.getEventListenerManager().jdbcExecuteStatementStart(); |
66 |
| - return connection( executionContext ) |
67 |
| - .update( finalSql, parameters ) |
68 |
| - .thenApply( result -> { |
69 |
| - // FIXME: I don't have a preparedStatement |
70 |
| -// expectationCheck.accept( result, preparedStatement ); |
71 |
| - return result; |
72 |
| - } ) |
73 |
| - .whenComplete( (result, t) -> session.getEventListenerManager().jdbcExecuteStatementEnd() ) |
74 |
| - .whenComplete( (result, t) -> executionContext.afterStatement( logicalConnection ) ); |
| 52 | + SharedSessionContractImplementor session = executionContext.getSession(); |
| 53 | + ReactiveSharedSessionContractImplementor reactiveSession = (ReactiveSharedSessionContractImplementor) session; |
| 54 | + |
| 55 | + return reactiveSession.reactiveAutoFlushIfRequired( jdbcMutation.getAffectedTableNames() ) |
| 56 | + .thenCompose( v -> { |
| 57 | + |
| 58 | + final LogicalConnectionImplementor logicalConnection = session |
| 59 | + .getJdbcCoordinator() |
| 60 | + .getLogicalConnection(); |
| 61 | + |
| 62 | + final JdbcServices jdbcServices = session.getJdbcServices(); |
| 63 | + final QueryOptions queryOptions = executionContext.getQueryOptions(); |
| 64 | + final String finalSql = finalSql( jdbcMutation, executionContext, jdbcServices, queryOptions ); |
| 65 | + |
| 66 | + Object[] parameters = PreparedStatementAdaptor |
| 67 | + .bind( statement -> prepareStatement( jdbcMutation, statement, jdbcParameterBindings, executionContext ) ); |
| 68 | + |
| 69 | + session.getEventListenerManager().jdbcExecuteStatementStart(); |
| 70 | + return connection( executionContext ) |
| 71 | + .update( finalSql, parameters ) |
| 72 | + .thenApply( result -> { |
| 73 | + // FIXME: I don't have a preparedStatement |
| 74 | + // expectationCheck.accept( result, preparedStatement ); |
| 75 | + return result; |
| 76 | + } ) |
| 77 | + .whenComplete( (result, t) -> session.getEventListenerManager().jdbcExecuteStatementEnd() ) |
| 78 | + .whenComplete( (result, t) -> executionContext.afterStatement( logicalConnection ) ); |
| 79 | + } ); |
75 | 80 | }
|
76 | 81 |
|
77 | 82 | private void prepareStatement(
|
|
0 commit comments