Top Description Methods
org.hibernate.jdbc

public Interface Batcher

Known Direct Implementers
org.hibernate.jdbc.AbstractBatcher
Imports
java.sql.CallableStatement, .Connection, .PreparedStatement, .ResultSet, .SQLException, org.hibernate.HibernateException, .ScrollMode, org.hibernate.dialect.Dialect

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.
Author
Gavin King
See Also
java.sql.PreparedStatement, org.hibernate.impl.SessionImpl

Method Summary

Modifier and TypeMethod and Description
public void
abortBatch(SQLException
the (not null) exception that is the reason for aborting
sqle
)

Must be called when an exception occurs

public void
addToBatch(Expectation expectation)

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

public void
cancelLastQuery()

Cancel the current query statement

public void
closeConnection(Connection conn)

Deprecated Obtain connections from ConnectionProvider instead
Dispose of the JDBC connection
public void
closeQueryStatement(PreparedStatement ps, ResultSet rs)

Close a prepared statement opened with prepareQueryStatement()

public void
closeStatement(PreparedStatement ps)

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

public void
closeStatements()

Close any query statements that were left lying around

public void
executeBatch()

Execute the batch

public ResultSet
getResultSet(PreparedStatement ps)

Execute the statement and return the result set

public ResultSet
getResultSet(CallableStatement ps, Dialect dialect)

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

public boolean
public Connection
openConnection()

Deprecated Obtain connections from ConnectionProvider instead
Obtain a JDBC connection
public String
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()).

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()).

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

Get a prepared statement for use in loading / querying.

public CallableStatement
prepareCallableStatement(String sql)

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

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

Get a prepared statement for use in loading / querying.

public PreparedStatement
prepareSelectStatement(String sql)

Get a non-batchable prepared statement to use for selecting.

public PreparedStatement
prepareStatement(String sql, boolean useGetGeneratedKeys)

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

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

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

public PreparedStatement
prepareStatement(String sql)

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

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.

Method Detail

abortBatchback to summary
public void abortBatch(SQLException sqle)

Must be called when an exception occurs

Parameters
sqle:SQLException

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

addToBatchback to summary
public void addToBatch(Expectation expectation) throws SQLException, HibernateException

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

cancelLastQueryback to summary
public void cancelLastQuery() throws HibernateException

Cancel the current query statement

closeConnectionback to summary
public void closeConnection(Connection conn) throws HibernateException

Deprecated

Obtain connections from ConnectionProvider instead

Dispose of the JDBC connection

closeQueryStatementback to summary
public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException

Close a prepared statement opened with prepareQueryStatement()

closeStatementback to summary
public void closeStatement(PreparedStatement ps) throws SQLException

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

closeStatementsback to summary
public void closeStatements()

Close any query statements that were left lying around

executeBatchback to summary
public void executeBatch() throws HibernateException

Execute the batch

getResultSetback to summary
public ResultSet getResultSet(PreparedStatement ps) throws SQLException

Execute the statement and return the result set

getResultSetback to summary
public ResultSet getResultSet(CallableStatement ps, Dialect dialect) throws SQLException

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

hasOpenResourcesback to summary
public boolean hasOpenResources()
openConnectionback to summary
public Connection openConnection() throws HibernateException

Deprecated

Obtain connections from ConnectionProvider instead

Obtain a JDBC connection

openResourceStatsAsStringback to summary
public String openResourceStatsAsString()
prepareBatchCallableStatementback to summary
public CallableStatement prepareBatchCallableStatement(String sql) throws SQLException, HibernateException

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.

See Also
Batcher#addToBatch
prepareBatchStatementback to summary
public PreparedStatement prepareBatchStatement(String sql) throws SQLException, HibernateException

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.

See Also
Batcher#addToBatch
prepareCallableQueryStatementback to summary
public CallableStatement prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) throws SQLException, HibernateException

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.

prepareCallableStatementback to summary
public CallableStatement prepareCallableStatement(String sql) throws SQLException, HibernateException

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

Must be explicitly released by closeStatement after use.

prepareQueryStatementback to summary
public PreparedStatement prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) throws SQLException, HibernateException

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.

prepareSelectStatementback to summary
public PreparedStatement prepareSelectStatement(String sql) throws SQLException, HibernateException

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

prepareStatementback to summary
public PreparedStatement prepareStatement(String sql, boolean useGetGeneratedKeys) throws SQLException, HibernateException

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

Must be explicitly released by closeStatement after use.

prepareStatementback to summary
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException, HibernateException

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

Must be explicitly released by closeStatement after use.

prepareStatementback to summary
public PreparedStatement prepareStatement(String sql) throws SQLException, HibernateException

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

Must be explicitly released by closeStatement after use.

setTransactionTimeoutback to summary
public void setTransactionTimeout(int seconds)

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

unsetTransactionTimeoutback to summary
public void unsetTransactionTimeout()

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