BatchAction (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.access.jdbc, class: BatchAction

# Class BatchAction

java.lang.Object
org.apache.cayenne.access.jdbc.BaseSQLAction
org.apache.cayenne.access.jdbc.BatchAction

All Implemented Interfaces:
  `SQLAction`

Direct Known Subclasses:
  `PostgresBatchAction, SQLServerBatchAction`

public class BatchAction extends BaseSQLAction

Since:
  1.2

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected RowDescriptor`
  `keyRowDescriptor`
  `protected BatchQuery`
  `query`
  `protected boolean`
  `runningAsBatch`

  ### Fields inherited from class BaseSQLAction

  `dataNode`
  Modifier and Type
  Field
  Description
  `protected DataNode`
  `dataNode`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BatchAction(BatchQuery query, DataNode dataNode, boolean runningAsBatch)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `canRunAsBatch()`
  `protected BatchTranslator`
  `createTranslator()`
  `BatchQuery`
  `getQuery()`
  `protected boolean`
  `hasGeneratedKeys()`
  Returns whether BatchQuery generates any keys.
  `void`
  `performAction(Connection connection, OperationObserver observer)`
  Executes a query using a strategy defined by the implementation.
  `protected PreparedStatement`
  `prepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys)`
  `protected void`
  `processGeneratedKeys(Statement statement, OperationObserver observer, List<BatchQueryRow> rows)`
  `protected void`
  `processGeneratedKeys(Statement statement, OperationObserver observer, BatchQueryRow row)`
  Implements generated keys extraction supported in JDBC 3.0 specification.
  `protected void`
  `runAsBatch(Connection con, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys)`
  `protected void`
  `runAsIndividualQueries(Connection connection, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys)`
  Executes batch as individual queries over the same prepared statement.
  `protected boolean`
  `supportsGeneratedKeys(boolean isBatch)`

  ### Methods inherited from class BaseSQLAction

  `getInMemoryOffset, readResultSet`
  Modifier and Type
  Method
  Description
  `protected int`
  `getInMemoryOffset(int queryOffset)`
  Returns a value of the offset that will be used to rewind the ResultSet within the SQL action before reading the result rows.
  `protected void`
  `readResultSet(ResultSet resultSet, RowDescriptor descriptor, Query query, OperationObserver delegate)`
  Helper method to process a ResultSet.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### runningAsBatch

    protected boolean runningAsBatch

  - ### query

    protected BatchQuery query

  - ### keyRowDescriptor

    protected RowDescriptor keyRowDescriptor

- ## Constructor Details

  - ### BatchAction

    public BatchAction(BatchQuery query, DataNode dataNode, boolean runningAsBatch)
    Since:
      4.0

- ## Method Details

  - ### getQuery

    public BatchQuery getQuery()
    Returns:
      Query which originated this action

  - ### performAction

    public void performAction(Connection connection, OperationObserver observer) throws Exception
    Description copied from interface: `SQLAction`
    Executes a query using a strategy defined by the implementation.
    Throws:
      `Exception`

  - ### canRunAsBatch

    protected boolean canRunAsBatch()

  - ### createTranslator

    protected BatchTranslator createTranslator()

  - ### runAsBatch

    protected void runAsBatch(Connection con, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys) throws Exception
    Throws:
      `Exception`

  - ### runAsIndividualQueries

    protected void runAsIndividualQueries(Connection connection, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys) throws SQLException, Exception
    Executes batch as individual queries over the same prepared statement.
    Throws:
      `SQLException`
      `Exception`

  - ### prepareStatement

    protected PreparedStatement prepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys) throws SQLException
    Throws:
      `SQLException`

  - ### supportsGeneratedKeys

    protected boolean supportsGeneratedKeys(boolean isBatch)

  - ### hasGeneratedKeys

    protected boolean hasGeneratedKeys()
    Returns whether BatchQuery generates any keys.

  - ### processGeneratedKeys

    protected void processGeneratedKeys(Statement statement, OperationObserver observer, BatchQueryRow row) throws SQLException
    Implements generated keys extraction supported in JDBC 3.0 specification.
    Throws:
      `SQLException`
    Since:
      4.0

  - ### processGeneratedKeys

    protected void processGeneratedKeys(Statement statement, OperationObserver observer, List<BatchQueryRow> rows) throws SQLException
    Throws:
      `SQLException`
    Since:
      4.2