Annotation Type SqlBatch


@Retention(RUNTIME) @Target(METHOD) public @interface SqlBatch
Annotate a method to indicate that it will create and execute a SQL batch. At least one bound argument must be an Iterator or Iterable, values from this will be taken and applied to each row of the batch. Non iterable bound arguments will be treated as constant values and bound to each row.

Unfortunately, because of how batches work, statement customizers and sql statement customizers which affect SQL generation will *not* work with batches. This primarily effects statement location and rewriting, which will always use the values defined on the bound Handle.

If you want to chunk up the logical batch into a number of smaller batches (say around 1000 rows at a time in order to not wreck havoc on the transaction log, you should see BatchChunkSize

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Controls whether to execute the batch chunks in a transaction.
    Returns the SQL string (or name) used for the batch.
  • Element Details

    • value

      String value
      Returns the SQL string (or name) used for the batch.
      Returns:
      the SQL string (or name) used for the batch.
      Default:
      ""
    • transactional

      boolean transactional
      Controls whether to execute the batch chunks in a transaction. Default is true.
      Returns:
      whether to execute the batch chunks in a transaction. Default is true (and it will be strange if you want otherwise).
      Default:
      true