站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Batcher (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.engine
Interface Batcher

All Known Implementing Classes:
BatcherImpl

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.

Author:
Gavin King
See Also:
PreparedStatement, SessionImpl

Method Summary
 void abortBatch(SQLException sqle)
          Must be called when an exception occurs
 void addToBatch(int expectedRowCount)
          Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())
 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 statement opened using prepareStatement()
 void closeStatements()
          Close any query statements that were left lying around
 void executeBatch()
          Execute the batch
 ResultSet getResultSet(PreparedStatement ps)
          Execute the statement and return the result set
 Connection openConnection()
          Obtain a JDBC connection
 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()).
 PreparedStatement prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)
          Get a prepared statement for use in loading / querying.
 PreparedStatement prepareStatement(String sql)
          Get a non-batchable prepared statement to use for inserting / deleting / updating.
 PreparedStatement prepareStatement(String sql, boolean useGetGeneratedKeys)
          Get a non-batchable prepared statement to use for inserting / deleting / updating.
 

Method Detail

prepareQueryStatement

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.

Throws:
SQLException
HibernateException

closeQueryStatement

public void closeQueryStatement(PreparedStatement ps,
                                ResultSet rs)
                         throws SQLException
Close a prepared statement opened with prepareQueryStatement()

Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          boolean useGetGeneratedKeys)
                                   throws SQLException,
                                          HibernateException
Get a non-batchable prepared statement to use for inserting / deleting / updating. Must be explicitly released by closeStatement()

Throws:
SQLException
HibernateException

prepareStatement

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

Throws:
SQLException
HibernateException

closeStatement

public void closeStatement(PreparedStatement ps)
                    throws SQLException
Close a prepared statement opened using prepareStatement()

Throws:
SQLException

prepareBatchStatement

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.

Throws:
SQLException
HibernateException
See Also:
addToBatch(int)

addToBatch

public void addToBatch(int expectedRowCount)
                throws SQLException,
                       HibernateException
Add an insert / delete / update to the current batch (might be called multiple times for single prepareBatchStatement())

Throws:
SQLException
HibernateException

executeBatch

public void executeBatch()
                  throws HibernateException
Execute the batch

Throws:
HibernateException

closeStatements

public void closeStatements()
Close any query statements that were left lying around


getResultSet

public ResultSet getResultSet(PreparedStatement ps)
                       throws SQLException
Execute the statement and return the result set

Throws:
SQLException

abortBatch

public void abortBatch(SQLException sqle)
Must be called when an exception occurs

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

openConnection

public Connection openConnection()
                          throws HibernateException
Obtain a JDBC connection

Throws:
HibernateException

closeConnection

public void closeConnection(Connection conn)
                     throws HibernateException
Dispose of the JDBC connection

Throws:
HibernateException

cancelLastQuery

public void cancelLastQuery()
                     throws HibernateException
Cancel the current query statement

Throws:
HibernateException