org.skife.jdbi.v2
Class PreparedBatch

java.lang.Object
  extended by org.skife.jdbi.v2.SQLStatement<PreparedBatch>
      extended by org.skife.jdbi.v2.PreparedBatch

public class PreparedBatch
extends SQLStatement<PreparedBatch>

Represents a prepared batch statement. That is, a sql statement compiled as a prepared statement, and then executed multiple times in a single batch. This is, generally, a very efficient way to execute large numbers of the same statement where the statement only varies by the arguments bound to it.


Method Summary
 PreparedBatchPart add()
          Add a statement (part) to this batch.
 PreparedBatchPart add(Map<String,? extends Object> args)
          Create a new batch part by binding values looked up in args to named parameters on the statement.
 PreparedBatch add(Object... args)
           
protected  void addCleanable(Cleanable cleanable)
           
protected  void addCustomizer(StatementCustomizer customizer)
           
protected  void addCustomizers(Collection<StatementCustomizer> customizers)
           
protected  void afterExecution(PreparedStatement stmt)
           
protected  void beforeExecution(PreparedStatement stmt)
           
protected  void cleanup()
           
 PreparedBatch define(Map<String,? extends Object> values)
          Adds all key/value pairs in the Map to the StatementContext.
 PreparedBatch define(String key, Object value)
          Specify a value on the statement context for this batch
 int[] execute()
          Execute the batch
protected  ConcreteStatementContext getConcreteContext()
           
 StatementContext getContext()
          Obtain the statement context associated with this statement
protected  org.skife.jdbi.v2.Foreman getForeman()
           
protected  Binding getParams()
           
 int getSize()
          The number of statements which are in this batch
protected  Collection<StatementCustomizer> getStatementCustomizers()
           
 int size()
          The number of statements which are in this batch
 
Methods inherited from class org.skife.jdbi.v2.SQLStatement
addStatementCustomizer, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bindASCIIStream, bindASCIIStream, bindAsInt, bindAsInt, bindAsInt, bindAsInt, bindBinaryStream, bindBinaryStream, bindBySqlType, bindBySqlType, bindFromMap, bindFromProperties, bindNamedArgumentFinder, bindNull, bindNull, cleanupHandle, cleanupHandle, getContainerMapperRegistry, getHandle, getLog, getParameters, getRewriter, getSql, getStatementBuilder, getStatementLocator, getTimingCollector, internalExecute, registerArgumentFactory, registerContainerFactory, setFetchDirection, setFetchDirection2, setQueryTimeout, setStatementLocator, setStatementLocator2, setStatementRewriter, setStatementRewriter2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public PreparedBatchPart add()
Add a statement (part) to this batch. You'll need to bindBinaryStream any arguments to the part.

Returns:
A part which can be used to bindBinaryStream parts to the statement

add

public PreparedBatchPart add(Map<String,? extends Object> args)
Create a new batch part by binding values looked up in args to named parameters on the statement.

Parameters:
args - map to bind arguments from for named parameters on the statement
Returns:
the new batch part

add

public PreparedBatch add(Object... args)

define

public PreparedBatch define(Map<String,? extends Object> values)
Adds all key/value pairs in the Map to the StatementContext.

Overrides:
define in class SQLStatement<PreparedBatch>
Parameters:
values - containing key/value pairs.
Returns:
this

define

public PreparedBatch define(String key,
                            Object value)
Specify a value on the statement context for this batch

Overrides:
define in class SQLStatement<PreparedBatch>
Parameters:
key - Key to access this value from the StatementContext
value - Value to setAttribute on the StatementContext
Returns:
self

execute

public int[] execute()
Execute the batch

Returns:
the number of rows modified or inserted per batch part.

getParams

protected Binding getParams()
Overrides:
getParams in class SQLStatement<PreparedBatch>

getSize

public int getSize()
The number of statements which are in this batch


size

public int size()
The number of statements which are in this batch


addCleanable

protected void addCleanable(Cleanable cleanable)

addCustomizer

protected void addCustomizer(StatementCustomizer customizer)

addCustomizers

protected void addCustomizers(Collection<StatementCustomizer> customizers)

afterExecution

protected final void afterExecution(PreparedStatement stmt)

beforeExecution

protected final void beforeExecution(PreparedStatement stmt)

cleanup

protected final void cleanup()

getConcreteContext

protected final ConcreteStatementContext getConcreteContext()

getContext

public final StatementContext getContext()
Obtain the statement context associated with this statement


getForeman

protected final org.skife.jdbi.v2.Foreman getForeman()

getStatementCustomizers

protected Collection<StatementCustomizer> getStatementCustomizers()


Copyright © 2013. All Rights Reserved.