public class BatchingStatementWrapper
extends GroovyObjectSupport
implements AutoCloseable
Class which delegates to a Statement but keeps track of a batch count size. If the batch count reaches the predefined number, this Statement does an executeBatch() automatically. If batchSize is zero, then no batching is performed.
| Modifiers | Name | Description |
|---|---|---|
protected int |
batchCount |
Number of commands added since the last delegate batch execution. |
protected int |
batchSize |
Automatic execution threshold; 0 disables automatic partitioning. |
protected Logger |
log |
Logger used for batch diagnostics. |
protected List<Integer> |
results |
Accumulated update counts across delegate batch executions. |
| Constructor and description |
|---|
BatchingStatementWrapper(Statement delegate, int batchSize, Logger log)Creates a batching wrapper for a statement. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addBatch(String sql)Adds a SQL command to the current batch. |
|
public void |
clearBatch()Clears the current batch and resets this wrapper's batch bookkeeping. |
|
public void |
close()Closes the wrapped statement. |
|
public int[] |
executeBatch()Executes any pending batched commands and returns the aggregated update counts. |
|
protected void |
incrementBatchCount()Increments batch count (after addBatch(..) has been called) and execute delegate.executeBatch() if batchSize has been reached. |
|
public Object |
invokeMethod(String name, Object args)Delegates unknown method calls to the wrapped Statement. |
|
protected void |
processResult(int[] lastResult)Incorporates one delegate batch execution result into this wrapper's state. |
|
protected void |
reset()Resets the wrapper's in-memory batch bookkeeping. |
| Methods inherited from class | Name |
|---|---|
class GroovyObjectSupport |
getMetaClass, setMetaClass |
Number of commands added since the last delegate batch execution.
Automatic execution threshold; 0 disables automatic partitioning.
Logger used for batch diagnostics.
Adds a SQL command to the current batch.
sql - the SQL command to addClears the current batch and resets this wrapper's batch bookkeeping.
Closes the wrapped statement.
Executes any pending batched commands and returns the aggregated update counts.
Increments batch count (after addBatch(..) has been called)
and execute delegate.executeBatch() if batchSize has been reached.
Delegates unknown method calls to the wrapped Statement.
name - the method nameargs - the method argumentsIncorporates one delegate batch execution result into this wrapper's state.
lastResult - the update counts returned by the wrapped statementResets the wrapper's in-memory batch bookkeeping.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.