public interface

Batcher

org.hibernate.jdbc.Batcher
Known Indirect Subclasses

Class Overview

Manages PreparedStatements for a session. Abstracts JDBC batching to maintain the illusion that a single logical batch exists for the whole session, even when batching is disabled. Provides transparent PreparedStatement caching.

Summary

Public Methods
abstract void abortBatch(SQLException sqle)
Must be called when an exception occurs
abstract void addToBatch(Expectation expectation)
Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())
abstract void cancelLastQuery()
Cancel the current query statement
abstract void closeConnection(Connection conn)
This method is deprecated. Obtain connections from ConnectionProvider instead
abstract void closeQueryStatement(PreparedStatement ps, ResultSet rs)
Close a prepared statement opened with prepareQueryStatement()
abstract void closeStatement(PreparedStatement ps)
Close a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()
abstract void closeStatements()
Close any query statements that were left lying around
abstract void executeBatch()
Execute the batch
abstract ResultSet getResultSet(PreparedStatement ps)
Execute the statement and return the result set
abstract ResultSet getResultSet(CallableStatement ps, Dialect dialect)
Execute the statement and return the result set from a callable statement
abstract boolean hasOpenResources()
abstract Connection openConnection()
This method is deprecated. Obtain connections from ConnectionProvider instead
abstract String openResourceStatsAsString()
abstract CallableStatement prepareBatchCallableStatement(String sql)
Get a batchable callable statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()).
abstract PreparedStatement prepareBatchStatement(String sql)
Get a batchable prepared statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()).
abstract CallableStatement prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)
Get a prepared statement for use in loading / querying.
abstract CallableStatement prepareCallableStatement(String sql)
Get a non-batchable callable statement to use for inserting / deleting / updating.
abstract PreparedStatement prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)
Get a prepared statement for use in loading / querying.
abstract PreparedStatement prepareSelectStatement(String sql)
Get a non-batchable prepared statement to use for selecting.
abstract PreparedStatement prepareStatement(String sql, String[] columnNames)
Get a non-batchable prepared statement to use for inserting / deleting / updating.
abstract PreparedStatement prepareStatement(String sql, boolean useGetGeneratedKeys)
Get a non-batchable prepared statement to use for inserting / deleting / updating, using JDBC3 getGeneratedKeys (prepareStatement(String, int)).
abstract PreparedStatement prepareStatement(String sql)
Get a non-batchable prepared statement to use for inserting / deleting / updating.
abstract void setTransactionTimeout(int seconds)
Set the transaction timeout to seconds later than the current system time.
abstract void unsetTransactionTimeout()
Unset the transaction timeout, called after the end of a transaction.

Public Methods

public abstract void abortBatch (SQLException sqle)

Must be called when an exception occurs

Parameters
sqle the (not null) exception that is the reason for aborting

public abstract void addToBatch (Expectation expectation)

Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())

public abstract void cancelLastQuery ()

Cancel the current query statement

public abstract void closeConnection (Connection conn)

This method is deprecated.
Obtain connections from ConnectionProvider instead

Dispose of the JDBC connection

public abstract void closeQueryStatement (PreparedStatement ps, ResultSet rs)

Close a prepared statement opened with prepareQueryStatement()

Throws
SQLException

public abstract void closeStatement (PreparedStatement ps)

Close a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()

Throws
SQLException

public abstract void closeStatements ()

Close any query statements that were left lying around

public abstract void executeBatch ()

Execute the batch

public abstract ResultSet getResultSet (PreparedStatement ps)

Execute the statement and return the result set

Throws
SQLException

public abstract ResultSet getResultSet (CallableStatement ps, Dialect dialect)

Execute the statement and return the result set from a callable statement

Throws
SQLException

public abstract boolean hasOpenResources ()

public abstract Connection openConnection ()

This method is deprecated.
Obtain connections from ConnectionProvider instead

Obtain a JDBC connection

public abstract String openResourceStatsAsString ()

public abstract CallableStatement prepareBatchCallableStatement (String sql)

Get a batchable callable statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()). After setting parameters, call addToBatch - do not execute the statement explicitly.

public abstract PreparedStatement prepareBatchStatement (String sql)

Get a batchable prepared statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()). After setting parameters, call addToBatch - do not execute the statement explicitly.

public abstract CallableStatement prepareCallableQueryStatement (String sql, boolean scrollable, ScrollMode scrollMode)

Get a prepared statement for use in loading / querying. If not explicitly released by closeQueryStatement(), it will be released when the session is closed or disconnected.

public abstract CallableStatement prepareCallableStatement (String sql)

Get a non-batchable callable statement to use for inserting / deleting / updating.

Must be explicitly released by closeStatement(PreparedStatement) after use.

public abstract PreparedStatement prepareQueryStatement (String sql, boolean scrollable, ScrollMode scrollMode)

Get a prepared statement for use in loading / querying. If not explicitly released by closeQueryStatement(), it will be released when the session is closed or disconnected.

public abstract PreparedStatement prepareSelectStatement (String sql)

Get a non-batchable prepared statement to use for selecting. Does not result in execution of the current batch.

public abstract PreparedStatement prepareStatement (String sql, String[] columnNames)

Get a non-batchable prepared statement to use for inserting / deleting / updating. using JDBC3 getGeneratedKeys (prepareStatement(String, String[])).

Must be explicitly released by closeStatement(PreparedStatement) after use.

public abstract PreparedStatement prepareStatement (String sql, boolean useGetGeneratedKeys)

Get a non-batchable prepared statement to use for inserting / deleting / updating, using JDBC3 getGeneratedKeys (prepareStatement(String, int)).

Must be explicitly released by closeStatement(PreparedStatement) after use.

public abstract PreparedStatement prepareStatement (String sql)

Get a non-batchable prepared statement to use for inserting / deleting / updating.

Must be explicitly released by closeStatement(PreparedStatement) after use.

public abstract void setTransactionTimeout (int seconds)

Set the transaction timeout to seconds later than the current system time.

public abstract void unsetTransactionTimeout ()

Unset the transaction timeout, called after the end of a transaction.