Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate.jdbc
Interface Batcher

All Known Implementing Classes:
  AbstractBatcher, BatchingBatcher, NonBatchingBatcher

    public interface Batcher

Manages `PreparedStatement`s 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(Expectation expectation)` 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)` Deprecated. Obtain connections from `ConnectionProvider` instead
`void` | `closeQueryStatement(PreparedStatement ps, ResultSet rs)` Close a prepared statement opened with `prepareQueryStatement()`
`void` | `closeStatement(PreparedStatement ps)` Close a prepared or callable statement opened using `prepareStatement()` or `prepareCallableStatement()`
`void` | `closeStatements()` Close any query statements that were left lying around
`void` | `executeBatch()` Execute the batch
`ResultSet` | `getResultSet(CallableStatement ps, Dialect dialect)` Execute the statement and return the result set from a callable statement
`ResultSet` | `getResultSet(PreparedStatement ps)` Execute the statement and return the result set
`boolean` | `hasOpenResources()`
`Connection` | `openConnection()` Deprecated. Obtain connections from `ConnectionProvider` instead
`String` | `openResourceStatsAsString()`
`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()`).
`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()`).
`CallableStatement` | `prepareCallableQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)` Get a prepared statement for use in loading / querying.
`CallableStatement` | `prepareCallableStatement(String sql)` Get a non-batchable callable statement to use for inserting / deleting / updating.
`PreparedStatement` | `prepareQueryStatement(String sql, boolean scrollable, ScrollMode scrollMode)` Get a prepared statement for use in loading / querying.
`PreparedStatement` | `prepareSelectStatement(String sql)` Get a non-batchable prepared statement to use for selecting.
`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, using JDBC3 getGeneratedKeys (`Connection.prepareStatement(String, int)`).
`PreparedStatement` | `prepareStatement(String sql, String[] columnNames)` Get a non-batchable prepared statement to use for inserting / deleting / updating.
`void` | `setTransactionTimeout(int seconds)` Set the transaction timeout to `seconds` later than the current system time.
`void` | `unsetTransactionTimeout()` Unset the transaction timeout, called after the end of a transaction.

Method Detail

### 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:
    `SQLException`
    `HibernateException`

### closeQueryStatement

    void closeQueryStatement(PreparedStatement ps,
                             ResultSet rs)
                             throws SQLException

  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:
    `SQLException`
    `HibernateException`

### prepareSelectStatement

    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.

  Throws:
    `SQLException`
    `HibernateException`

### 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 by `closeStatement(java.sql.PreparedStatement)` after use.

  Throws:
    `SQLException`
    `HibernateException`

### 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 by `closeStatement(java.sql.PreparedStatement)` after use.

  Throws:
    `SQLException`
    `HibernateException`

### prepareStatement

    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(java.sql.PreparedStatement)` after use.

  Throws:
    `SQLException`
    `HibernateException`

### prepareCallableStatement

    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(java.sql.PreparedStatement)` after use.

  Throws:
    `SQLException`
    `HibernateException`

### closeStatement

    void closeStatement(PreparedStatement ps)
                        throws SQLException

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

  Throws:
    `SQLException`

### prepareBatchStatement

    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(org.hibernate.jdbc.Expectation)`

### prepareBatchCallableStatement

    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.

  Throws:
    `SQLException`
    `HibernateException`
  See Also:
    `addToBatch(org.hibernate.jdbc.Expectation)`

### addToBatch

    void addToBatch(Expectation expectation)
                    throws SQLException,
                           HibernateException

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

  Throws:
    `SQLException`
    `HibernateException`

### executeBatch

    void executeBatch()
                      throws HibernateException

  Execute the batch

  Throws:
    `HibernateException`

### closeStatements

    void closeStatements()

  Close any query statements that were left lying around

### getResultSet

    ResultSet getResultSet(PreparedStatement ps)
                           throws SQLException

  Execute the statement and return the result set

  Throws:
    `SQLException`

### getResultSet

    ResultSet getResultSet(CallableStatement ps,
                           Dialect dialect)
                           throws SQLException

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

  Throws:
    `SQLException`

### abortBatch

    void abortBatch(SQLException sqle)

  Must be called when an exception occurs

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

### cancelLastQuery

    void cancelLastQuery()
                         throws HibernateException

  Cancel the current query statement

  Throws:
    `HibernateException`

### hasOpenResources

    boolean hasOpenResources()

### openResourceStatsAsString

    String openResourceStatsAsString()

### openConnection

    Connection openConnection()
                              throws HibernateException

  Deprecated. Obtain connections from `ConnectionProvider` instead

  Obtain a JDBC connection

  Throws:
    `HibernateException`

### closeConnection

    void closeConnection(Connection conn)
                         throws HibernateException

  Deprecated. Obtain connections from `ConnectionProvider` instead

  Dispose 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.