Class BatchingConnection

  • All Implemented Interfaces:
    ReactiveConnection

    public class BatchingConnection
    extends java.lang.Object
    implements ReactiveConnection
    A ReactiveConnection that automatically performs batching of insert, update, and delete statements, relieving the client persister code of the responsibility to manage batching. Actual SQL statements are delegated to a given ReactiveConnection which only supports explicit batching using update(String, List).

    Note that in Hibernate core, the responsibilities of this class are handled by JdbcCoordinator and the Batch interface. However, the model used there is not easily adaptable to the reactive paradigm.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.lang.Void> beginTransaction()  
      java.util.concurrent.CompletionStage<java.lang.Void> close()  
      java.util.concurrent.CompletionStage<java.lang.Void> commitTransaction()  
      java.util.concurrent.CompletionStage<java.lang.Void> execute​(java.lang.String sql)  
      java.util.concurrent.CompletionStage<java.lang.Void> executeBatch()  
      java.util.concurrent.CompletionStage<java.lang.Void> executeOutsideTransaction​(java.lang.String sql)  
      java.util.concurrent.CompletionStage<java.lang.Void> executeUnprepared​(java.lang.String sql)
      Run sql as statement (instead of preparedStatement)
      <T> java.util.concurrent.CompletionStage<T> insertAndSelectIdentifier​(java.lang.String sql, java.lang.Object[] paramValues, java.lang.Class<T> idClass, java.lang.String idColumnName)  
      java.util.concurrent.CompletionStage<java.lang.Void> rollbackTransaction()  
      java.util.concurrent.CompletionStage<ReactiveConnection.Result> select​(java.lang.String sql)  
      java.util.concurrent.CompletionStage<ReactiveConnection.Result> select​(java.lang.String sql, java.lang.Object[] paramValues)  
      <T> java.util.concurrent.CompletionStage<T> selectIdentifier​(java.lang.String sql, java.lang.Object[] paramValues, java.lang.Class<T> idClass)  
      java.util.concurrent.CompletionStage<java.sql.ResultSet> selectJdbc​(java.lang.String sql, java.lang.Object[] paramValues)  
      java.util.concurrent.CompletionStage<java.sql.ResultSet> selectJdbcOutsideTransaction​(java.lang.String sql, java.lang.Object[] paramValues)
      This method is intended to be used only for queries returning a ResultSet that must be executed outside of any "current" transaction (i.e with autocommit=true).
      java.util.concurrent.CompletionStage<java.lang.Integer> update​(java.lang.String sql)  
      java.util.concurrent.CompletionStage<java.lang.Integer> update​(java.lang.String sql, java.lang.Object[] paramValues)  
      java.util.concurrent.CompletionStage<java.lang.Void> update​(java.lang.String sql, java.lang.Object[] paramValues, boolean allowBatching, ReactiveConnection.Expectation expectation)  
      java.util.concurrent.CompletionStage<int[]> update​(java.lang.String sql, java.util.List<java.lang.Object[]> paramValues)  
      ReactiveConnection withBatchSize​(int batchSize)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BatchingConnection

        public BatchingConnection​(ReactiveConnection delegate,
                                  int batchSize)
    • Method Detail

      • executeBatch

        public java.util.concurrent.CompletionStage<java.lang.Void> executeBatch()
        Specified by:
        executeBatch in interface ReactiveConnection
      • execute

        public java.util.concurrent.CompletionStage<java.lang.Void> execute​(java.lang.String sql)
        Specified by:
        execute in interface ReactiveConnection
      • executeUnprepared

        public java.util.concurrent.CompletionStage<java.lang.Void> executeUnprepared​(java.lang.String sql)
        Description copied from interface: ReactiveConnection
        Run sql as statement (instead of preparedStatement)
        Specified by:
        executeUnprepared in interface ReactiveConnection
      • executeOutsideTransaction

        public java.util.concurrent.CompletionStage<java.lang.Void> executeOutsideTransaction​(java.lang.String sql)
        Specified by:
        executeOutsideTransaction in interface ReactiveConnection
      • update

        public java.util.concurrent.CompletionStage<java.lang.Integer> update​(java.lang.String sql)
        Specified by:
        update in interface ReactiveConnection
      • update

        public java.util.concurrent.CompletionStage<java.lang.Integer> update​(java.lang.String sql,
                                                                              java.lang.Object[] paramValues)
        Specified by:
        update in interface ReactiveConnection
      • update

        public java.util.concurrent.CompletionStage<int[]> update​(java.lang.String sql,
                                                                  java.util.List<java.lang.Object[]> paramValues)
        Specified by:
        update in interface ReactiveConnection
      • insertAndSelectIdentifier

        public <T> java.util.concurrent.CompletionStage<T> insertAndSelectIdentifier​(java.lang.String sql,
                                                                                     java.lang.Object[] paramValues,
                                                                                     java.lang.Class<T> idClass,
                                                                                     java.lang.String idColumnName)
        Specified by:
        insertAndSelectIdentifier in interface ReactiveConnection
      • selectJdbc

        public java.util.concurrent.CompletionStage<java.sql.ResultSet> selectJdbc​(java.lang.String sql,
                                                                                   java.lang.Object[] paramValues)
        Specified by:
        selectJdbc in interface ReactiveConnection
      • selectJdbcOutsideTransaction

        public java.util.concurrent.CompletionStage<java.sql.ResultSet> selectJdbcOutsideTransaction​(java.lang.String sql,
                                                                                                     java.lang.Object[] paramValues)
        Description copied from interface: ReactiveConnection
        This method is intended to be used only for queries returning a ResultSet that must be executed outside of any "current" transaction (i.e with autocommit=true).

        For example, it would be appropriate to use this method when performing queries on information_schema or system tables in order to obtain metadata information about catalogs, schemas, tables, etc.

        Specified by:
        selectJdbcOutsideTransaction in interface ReactiveConnection
        Parameters:
        sql - - the query to execute outside of a transaction
        paramValues - - a non-null array of parameter values
        Returns:
        the CompletionStage from executing the query.
      • selectIdentifier

        public <T> java.util.concurrent.CompletionStage<T> selectIdentifier​(java.lang.String sql,
                                                                            java.lang.Object[] paramValues,
                                                                            java.lang.Class<T> idClass)
        Specified by:
        selectIdentifier in interface ReactiveConnection
      • close

        public java.util.concurrent.CompletionStage<java.lang.Void> close()
        Specified by:
        close in interface ReactiveConnection