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

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


net.sf.hibernate.impl
Class BatcherImpl

java.lang.Object
  extended bynet.sf.hibernate.impl.BatcherImpl
All Implemented Interfaces:
Batcher
Direct Known Subclasses:
BatchingBatcher, NonBatchingBatcher

public abstract class BatcherImpl
extends Object
implements Batcher

Manages prepared statements and batching.

Author:
Gavin King

Field Summary
protected static org.apache.commons.logging.Log log
           
protected static org.apache.commons.logging.Log sqlLog
           
 
Constructor Summary
BatcherImpl(SessionImplementor session)
           
 
Method Summary
 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 statement opened using prepareStatement()
 void closeStatements()
          Close any query statements that were left lying around
protected  JDBCException convert(SQLException sqlException, String message)
           
protected abstract  void doExecuteBatch(PreparedStatement ps)
           
 void executeBatch()
          Execute the batch
protected  SessionFactoryImplementor getFactory()
           
 ResultSet getResultSet(PreparedStatement ps)
          Execute the statement and return the result set
protected  SessionImplementor getSession()
           
protected  PreparedStatement getStatement()
           
 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 getGeneratedKeys)
          Get a non-batchable prepared statement to use for inserting / deleting / updating.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.engine.Batcher
addToBatch
 

Field Detail

log

protected static final org.apache.commons.logging.Log log

sqlLog

protected static final org.apache.commons.logging.Log sqlLog
Constructor Detail

BatcherImpl

public BatcherImpl(SessionImplementor session)
Method Detail

getStatement

protected PreparedStatement getStatement()

prepareStatement

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

Specified by:
prepareStatement in interface Batcher
Throws:
SQLException
HibernateException

prepareStatement

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

Specified by:
prepareStatement in interface Batcher
Throws:
SQLException
HibernateException

prepareQueryStatement

public PreparedStatement prepareQueryStatement(String sql,
                                               boolean scrollable,
                                               ScrollMode scrollMode)
                                        throws SQLException,
                                               HibernateException
Description copied from interface: Batcher
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.

Specified by:
prepareQueryStatement in interface Batcher
Throws:
SQLException
HibernateException

abortBatch

public void abortBatch(SQLException sqle)
Description copied from interface: Batcher
Must be called when an exception occurs

Specified by:
abortBatch in interface Batcher
Parameters:
sqle - the (not null) exception that is the reason for aborting

getResultSet

public ResultSet getResultSet(PreparedStatement ps)
                       throws SQLException
Description copied from interface: Batcher
Execute the statement and return the result set

Specified by:
getResultSet in interface Batcher
Throws:
SQLException

closeQueryStatement

public void closeQueryStatement(PreparedStatement ps,
                                ResultSet rs)
                         throws SQLException
Description copied from interface: Batcher
Close a prepared statement opened with prepareQueryStatement()

Specified by:
closeQueryStatement in interface Batcher
Throws:
SQLException

prepareBatchStatement

public PreparedStatement prepareBatchStatement(String sql)
                                        throws SQLException,
                                               HibernateException
Description copied from interface: Batcher
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.

Specified by:
prepareBatchStatement in interface Batcher
Throws:
SQLException
HibernateException
See Also:
Batcher.addToBatch(int)

executeBatch

public void executeBatch()
                  throws HibernateException
Description copied from interface: Batcher
Execute the batch

Specified by:
executeBatch in interface Batcher
Throws:
HibernateException

closeStatement

public void closeStatement(PreparedStatement ps)
                    throws SQLException
Description copied from interface: Batcher
Close a prepared statement opened using prepareStatement()

Specified by:
closeStatement in interface Batcher
Throws:
SQLException

closeStatements

public void closeStatements()
Description copied from interface: Batcher
Close any query statements that were left lying around

Specified by:
closeStatements in interface Batcher

doExecuteBatch

protected abstract void doExecuteBatch(PreparedStatement ps)
                                throws SQLException,
                                       HibernateException
Throws:
SQLException
HibernateException

getSession

protected SessionImplementor getSession()

getFactory

protected SessionFactoryImplementor getFactory()

openConnection

public Connection openConnection()
                          throws HibernateException
Description copied from interface: Batcher
Obtain a JDBC connection

Specified by:
openConnection in interface Batcher
Throws:
HibernateException

closeConnection

public void closeConnection(Connection conn)
                     throws HibernateException
Description copied from interface: Batcher
Dispose of the JDBC connection

Specified by:
closeConnection in interface Batcher
Throws:
HibernateException

cancelLastQuery

public void cancelLastQuery()
                     throws HibernateException
Description copied from interface: Batcher
Cancel the current query statement

Specified by:
cancelLastQuery in interface Batcher
Throws:
HibernateException

convert

protected JDBCException convert(SQLException sqlException,
                                String message)