Package org.apache.cayenne.access.jdbc
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 RowDescriptorkeyRowDescriptorprotected BatchQueryqueryprotected booleanrunningAsBatch-
Fields inherited from class org.apache.cayenne.access.jdbc.BaseSQLAction
dataNode
-
-
Constructor Summary
Constructors Constructor Description BatchAction(BatchQuery query, DataNode dataNode, boolean runningAsBatch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BatchTranslatorcreateTranslator()BatchQuerygetQuery()protected booleanhasGeneratedKeys()Returns whether BatchQuery generates any keys.voidperformAction(Connection connection, OperationObserver observer)Executes a query using a strategy defined by the implementation.protected PreparedStatementprepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys)protected voidprocessGeneratedKeys(Statement statement, OperationObserver observer, BatchQueryRow row)Implements generated keys extraction supported in JDBC 3.0 specification.protected voidrunAsBatch(Connection con, BatchTranslator translator, OperationObserver delegate)protected voidrunAsIndividualQueries(Connection connection, BatchTranslator translator, OperationObserver delegate, boolean generatesKeys)Executes batch as individual queries over the same prepared statement.-
Methods inherited from class org.apache.cayenne.access.jdbc.BaseSQLAction
getInMemoryOffset, readResultSet
-
-
-
-
Field Detail
-
runningAsBatch
protected boolean runningAsBatch
-
query
protected BatchQuery query
-
keyRowDescriptor
protected RowDescriptor keyRowDescriptor
-
-
Constructor Detail
-
BatchAction
public BatchAction(BatchQuery query, DataNode dataNode, boolean runningAsBatch)
- Since:
- 4.0
-
-
Method Detail
-
getQuery
public BatchQuery getQuery()
- Returns:
- Query which originated this action
-
performAction
public void performAction(Connection connection, OperationObserver observer) throws SQLException, Exception
Description copied from interface:SQLActionExecutes a query using a strategy defined by the implementation.- Throws:
SQLExceptionException
-
createTranslator
protected BatchTranslator createTranslator()
-
runAsBatch
protected void runAsBatch(Connection con, BatchTranslator translator, OperationObserver delegate) throws SQLException, Exception
- Throws:
SQLExceptionException
-
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:
SQLExceptionException
-
prepareStatement
protected PreparedStatement prepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys) throws SQLException
- Throws:
SQLException
-
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
-
-