Package org.hibernate.jdbc
Class AbstractBatcher
java.lang.Object
org.hibernate.jdbc.AbstractBatcher
- All Implemented Interfaces:
Batcher
- Direct Known Subclasses:
BatchingBatcher,NonBatchingBatcher
Manages prepared statements and batching.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBatcher(ConnectionManager connectionManager, Interceptor interceptor) -
Method Summary
Modifier and TypeMethodDescriptionvoidabortBatch(SQLException sqle) Must be called when an exception occursvoidCancel the current query statementvoidcloseConnection(Connection conn) Dispose of the JDBC connectionvoidClose a prepared statement opened with prepareQueryStatement()voidClose a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()voidActually releases the batcher, allowing it to cleanup internally held resources.protected abstract voidvoidExecute the batchprotected SessionFactoryImplementorgetResultSet(CallableStatement ps, Dialect dialect) Execute the statement and return the result set from a callable statementExecute the statement and return the result setprotected PreparedStatementbooleanObtain a JDBC connectionGet 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 getGeneratedKeys) 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.jdbc.Batcher
addToBatch
-
Field Details
-
log
-
-
Constructor Details
-
AbstractBatcher
-
-
Method Details
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) Description copied from interface:BatcherSet the transaction timeout to seconds later than the current system time.- Specified by:
setTransactionTimeoutin interfaceBatcher
-
unsetTransactionTimeout
public void unsetTransactionTimeout()Description copied from interface:BatcherUnset the transaction timeout, called after the end of a transaction.- Specified by:
unsetTransactionTimeoutin interfaceBatcher
-
getStatement
-
prepareCallableStatement
public CallableStatement prepareCallableStatement(String sql) throws SQLException, HibernateException Description copied from interface:BatcherGet a non-batchable callable statement to use for inserting / deleting / updating. Must be explicitly released byBatcher.closeStatement(java.sql.PreparedStatement)after use.- Specified by:
prepareCallableStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareStatement
Description copied from interface:BatcherGet a non-batchable prepared statement to use for inserting / deleting / updating. Must be explicitly released byBatcher.closeStatement(java.sql.PreparedStatement)after use.- Specified by:
prepareStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, boolean getGeneratedKeys) throws SQLException, HibernateException Description copied from interface:BatcherGet a non-batchable prepared statement to use for inserting / deleting / updating, using JDBC3 getGeneratedKeys (Connection.prepareStatement(String, int)). Must be explicitly released byBatcher.closeStatement(java.sql.PreparedStatement)after use.- Specified by:
prepareStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException, HibernateException Description copied from interface:BatcherGet a non-batchable prepared statement to use for inserting / deleting / updating. using JDBC3 getGeneratedKeys (Connection.prepareStatement(String, String[])). Must be explicitly released byBatcher.closeStatement(java.sql.PreparedStatement)after use.- Specified by:
prepareStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareSelectStatement
Description copied from interface:BatcherGet a non-batchable prepared statement to use for selecting. Does not result in execution of the current batch.- Specified by:
prepareSelectStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareQueryStatement
public PreparedStatement prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) throws SQLException, HibernateException Description copied from interface:BatcherGet 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.- Specified by:
prepareQueryStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
prepareCallableQueryStatement
public CallableStatement prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode) throws SQLException, HibernateException Description copied from interface:BatcherGet 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.- Specified by:
prepareCallableQueryStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException
-
abortBatch
Description copied from interface:BatcherMust be called when an exception occurs- Specified by:
abortBatchin interfaceBatcher- Parameters:
sqle- the (not null) exception that is the reason for aborting
-
getResultSet
Description copied from interface:BatcherExecute the statement and return the result set- Specified by:
getResultSetin interfaceBatcher- Throws:
SQLException
-
getResultSet
Description copied from interface:BatcherExecute the statement and return the result set from a callable statement- Specified by:
getResultSetin interfaceBatcher- Throws:
SQLException
-
closeQueryStatement
Description copied from interface:BatcherClose a prepared statement opened with prepareQueryStatement()- Specified by:
closeQueryStatementin interfaceBatcher- Throws:
SQLException
-
prepareBatchStatement
Description copied from interface:BatcherGet 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.- Specified by:
prepareBatchStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException- See Also:
-
prepareBatchCallableStatement
public CallableStatement prepareBatchCallableStatement(String sql) throws SQLException, HibernateException Description copied from interface:BatcherGet 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.- Specified by:
prepareBatchCallableStatementin interfaceBatcher- Throws:
SQLExceptionHibernateException- See Also:
-
executeBatch
Description copied from interface:BatcherExecute the batch- Specified by:
executeBatchin interfaceBatcher- Throws:
HibernateException
-
closeStatement
Description copied from interface:BatcherClose a prepared or callable statement opened using prepareStatement() or prepareCallableStatement()- Specified by:
closeStatementin interfaceBatcher- Throws:
SQLException
-
closeStatements
public void closeStatements()Actually releases the batcher, allowing it to cleanup internally held resources.- Specified by:
closeStatementsin interfaceBatcher
-
doExecuteBatch
protected abstract void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException - Throws:
SQLExceptionHibernateException
-
getFactory
-
openConnection
Description copied from interface:BatcherObtain a JDBC connection- Specified by:
openConnectionin interfaceBatcher- Throws:
HibernateException
-
closeConnection
Description copied from interface:BatcherDispose of the JDBC connection- Specified by:
closeConnectionin interfaceBatcher- Throws:
HibernateException
-
cancelLastQuery
Description copied from interface:BatcherCancel the current query statement- Specified by:
cancelLastQueryin interfaceBatcher- Throws:
HibernateException
-
hasOpenResources
public boolean hasOpenResources()- Specified by:
hasOpenResourcesin interfaceBatcher
-
openResourceStatsAsString
- Specified by:
openResourceStatsAsStringin interfaceBatcher
-