Package org.hibernate.jdbc
Interface Batcher
- All Known Implementing Classes:
AbstractBatcher,BatchingBatcher,NonBatchingBatcher
public interface Batcher
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.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidabortBatch(SQLException sqle) Must be called when an exception occursvoidaddToBatch(Expectation expectation) Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())voidCancel the current query statementvoidcloseConnection(Connection conn) Deprecated.voidClose a prepared statement opened with prepareQueryStatement()voidClose a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()voidClose any query statements that were left lying aroundvoidExecute the batchgetResultSet(CallableStatement ps, Dialect dialect) Execute the statement and return the result set from a callable statementExecute the statement and return the result setbooleanDeprecated.Obtain connections frominsteadinvalid reference
ConnectionProviderGet a batchable callable statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()).Get a batchable prepared statement to use for inserting / deleting / updating (might be called many times before a single call to executeBatch()).prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) Get a prepared statement for use in loading / querying.Get a non-batchable callable statement to use for inserting / deleting / updating.prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) Get a prepared statement for use in loading / querying.Get a non-batchable prepared statement to use for selecting.prepareStatement(String sql) Get a non-batchable prepared statement to use for inserting / deleting / updating.prepareStatement(String sql, boolean useGetGeneratedKeys) Get a non-batchable prepared statement to use for inserting / deleting / updating, using JDBC3 getGeneratedKeys (Connection.prepareStatement(String, int)).prepareStatement(String sql, String[] columnNames) Get a non-batchable prepared statement to use for inserting / deleting / updating.voidsetTransactionTimeout(int seconds) Set the transaction timeout to seconds later than the current system time.voidUnset the transaction timeout, called after the end of a transaction.
-
Method Details
-
prepareQueryStatement
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.- Throws:
SQLExceptionHibernateException
-
closeQueryStatement
Close a prepared statement opened with prepareQueryStatement()- Throws:
SQLException
-
prepareCallableQueryStatement
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.- Throws:
SQLExceptionHibernateException
-
prepareSelectStatement
Get a non-batchable prepared statement to use for selecting. Does not result in execution of the current batch.- Throws:
SQLExceptionHibernateException
-
prepareStatement
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 bycloseStatement(java.sql.PreparedStatement)after use.- Throws:
SQLExceptionHibernateException
-
prepareStatement
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 bycloseStatement(java.sql.PreparedStatement)after use.- Throws:
SQLExceptionHibernateException
-
prepareStatement
Get a non-batchable prepared statement to use for inserting / deleting / updating. Must be explicitly released bycloseStatement(java.sql.PreparedStatement)after use.- Throws:
SQLExceptionHibernateException
-
prepareCallableStatement
Get a non-batchable callable statement to use for inserting / deleting / updating. Must be explicitly released bycloseStatement(java.sql.PreparedStatement)after use.- Throws:
SQLExceptionHibernateException
-
closeStatement
Close a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()- Throws:
SQLException
-
prepareBatchStatement
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.- Throws:
SQLExceptionHibernateException- See Also:
-
prepareBatchCallableStatement
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.- Throws:
SQLExceptionHibernateException- See Also:
-
addToBatch
Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())- Throws:
SQLExceptionHibernateException
-
executeBatch
Execute the batch- Throws:
HibernateException
-
closeStatements
void closeStatements()Close any query statements that were left lying around -
getResultSet
Execute the statement and return the result set- Throws:
SQLException
-
getResultSet
Execute the statement and return the result set from a callable statement- Throws:
SQLException
-
abortBatch
Must be called when an exception occurs- Parameters:
sqle- the (not null) exception that is the reason for aborting
-
cancelLastQuery
Cancel the current query statement- Throws:
HibernateException
-
hasOpenResources
boolean hasOpenResources() -
openResourceStatsAsString
String openResourceStatsAsString() -
openConnection
Deprecated.Obtain connections frominsteadinvalid reference
ConnectionProviderObtain a JDBC connection- Throws:
HibernateException
-
closeConnection
Deprecated.Obtain connections frominsteadinvalid reference
ConnectionProviderDispose of the JDBC connection- Throws:
HibernateException
-
setTransactionTimeout
void setTransactionTimeout(int seconds) Set the transaction timeout to seconds later than the current system time. -
unsetTransactionTimeout
void unsetTransactionTimeout()Unset the transaction timeout, called after the end of a transaction.
-
invalid reference