public abstract class

AbstractBatcher

extends Object
implements Batcher
java.lang.Object
   ↳ org.hibernate.jdbc.AbstractBatcher
Known Direct Subclasses

Class Overview

Manages prepared statements and batching.

Summary

Fields
protected static final Logger log
Public Constructors
AbstractBatcher(ConnectionManager connectionManager, Interceptor interceptor)
Public Methods
void abortBatch(SQLException sqle)
Must be called when an exception occurs
void cancelLastQuery()
Cancel the current query statement
void closeConnection(Connection conn)
Dispose of the JDBC connection
void closeQueryStatement(PreparedStatement ps, ResultSet rs)
Close a prepared statement opened with prepareQueryStatement()
void closeStatement(PreparedStatement ps)
Close a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()
void closeStatements()
Actually releases the batcher, allowing it to cleanup internally held resources.
void executeBatch()
Execute the batch
ResultSet getResultSet(CallableStatement ps, Dialect dialect)
Execute the statement and return the result set from a callable statement
ResultSet getResultSet(PreparedStatement ps)
Execute the statement and return the result set
boolean hasOpenResources()
Connection openConnection()
Obtain a JDBC connection
String openResourceStatsAsString()
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()).
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()).
CallableStatement prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)
Get a prepared statement for use in loading / querying.
CallableStatement prepareCallableStatement(String sql)
Get a non-batchable callable statement to use for inserting / deleting / updating.
PreparedStatement prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)
Get a prepared statement for use in loading / querying.
PreparedStatement prepareSelectStatement(String sql)
Get a non-batchable prepared statement to use for selecting.
PreparedStatement prepareStatement(String sql, String[] columnNames)
Get a non-batchable prepared statement to use for inserting / deleting / updating.
PreparedStatement prepareStatement(String sql, boolean getGeneratedKeys)
Get a non-batchable prepared statement to use for inserting / deleting / updating, using JDBC3 getGeneratedKeys (prepareStatement(String, int)).
PreparedStatement prepareStatement(String sql)
Get a non-batchable prepared statement to use for inserting / deleting / updating.
void setTransactionTimeout(int seconds)
Set the transaction timeout to seconds later than the current system time.
void unsetTransactionTimeout()
Unset the transaction timeout, called after the end of a transaction.
Protected Methods
abstract void doExecuteBatch(PreparedStatement ps)
SessionFactoryImplementor getFactory()
PreparedStatement getStatement()
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.jdbc.Batcher

Fields

protected static final Logger log

Public Constructors

public AbstractBatcher (ConnectionManager connectionManager, Interceptor interceptor)

Public Methods

public void abortBatch (SQLException sqle)

Must be called when an exception occurs

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

public void cancelLastQuery ()

Cancel the current query statement

public void closeConnection (Connection conn)

Dispose of the JDBC connection

public void closeQueryStatement (PreparedStatement ps, ResultSet rs)

Close a prepared statement opened with prepareQueryStatement()

Throws
SQLException

public void closeStatement (PreparedStatement ps)

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

Throws
SQLException

public void closeStatements ()

Actually releases the batcher, allowing it to cleanup internally held resources.

public void executeBatch ()

Execute the batch

public ResultSet getResultSet (CallableStatement ps, Dialect dialect)

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

Throws
SQLException

public ResultSet getResultSet (PreparedStatement ps)

Execute the statement and return the result set

Throws
SQLException

public boolean hasOpenResources ()

public Connection openConnection ()

Obtain a JDBC connection

public String openResourceStatsAsString ()

public 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 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 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 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 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 PreparedStatement prepareSelectStatement (String sql)

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

public 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 PreparedStatement prepareStatement (String sql, boolean getGeneratedKeys)

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 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 void setTransactionTimeout (int seconds)

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

public void unsetTransactionTimeout ()

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

Protected Methods

protected abstract void doExecuteBatch (PreparedStatement ps)

protected SessionFactoryImplementor getFactory ()

protected PreparedStatement getStatement ()