Interface BatchBuilder

All Superinterfaces:
Serializable, Service

@Incubating @JavaServiceLoadable public interface BatchBuilder extends Service
A builder for Batch instances.

The core batch lifecycle is split into specializations. Implementors should create a GroupedBatch for the general mutation executor path, and may additionally create a SingleStatementBatch for execution paths that bind directly to one statement shape.

A custom BatchBuilder may be selected either by setting the configuration property "hibernate.jdbc.batch.builder", or by registering it as a Java service.

  • Method Details

    • buildGroupedBatch

      GroupedBatch buildGroupedBatch(BatchKey key, Integer batchSize, Supplier<PreparedStatementGroup> statementGroupSupplier, JdbcCoordinator jdbcCoordinator)
      Build a batch for the general mutation executor infrastructure.

      The returned batch owns the PreparedStatementGroup produced by statementGroupSupplier. The supplier is passed instead of an eagerly created group so implementations may decide exactly when statement-group construction should happen.

      Parameters:
      key - key identifying compatible rows for the batch
      batchSize - explicit batch size override, or null to use the builder's default
      statementGroupSupplier - supplier for the statement group owned by the batch
      jdbcCoordinator - JDBC coordinator that will own the active batch
      Returns:
      a grouped batch instance
    • buildSingleStatementBatch

      default SingleStatementBatch buildSingleStatementBatch(BatchKey key, Integer batchSize, PreparableMutationOperation mutationOperation, JdbcCoordinator jdbcCoordinator)
      Build a batch for a single JDBC statement shape.

      The default implementation throws because existing custom builders written for grouped mutation batching do not necessarily know how to build this specialization. Builders that want to support graph-style single statement batching should override this method.

      Parameters:
      key - key identifying compatible rows for the batch
      batchSize - explicit batch size override, or null to use the builder's default
      mutationOperation - preparable mutation operation representing the single statement shape
      jdbcCoordinator - JDBC coordinator that will own the active batch
      Returns:
      a single-statement batch instance