org.apache.cayenne.access.jdbc

## Class SQLTemplateAction

- java.lang.Object
- - org.apache.cayenne.access.jdbc.SQLTemplateAction

- All Implemented Interfaces:
    SQLAction
  Direct Known Subclasses:
    FrontBaseTemplateAction

      public class SQLTemplateAction
      extends Object
      implements SQLAction

  Implements a strategy for execution of SQLTemplates.
  Since:
    1.2 replaces SQLTemplateExecutionPlan

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DataNode` | `dataNode`
    `protected DbAdapter` | `dbAdapter`
    `protected DbEntity` | `dbEntity`
    `protected SQLTemplate` | `query`
    `protected QueryMetadata` | `queryMetadata`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SQLTemplateAction(SQLTemplate query, DataNode dataNode)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `bind(PreparedStatement preparedStatement, ParameterBinding[] bindings)` Binds parameters to the PreparedStatement.
    `protected RowDescriptorBuilder` | `configureRowDescriptorBuilder(SQLStatement compiled, ResultSet resultSet)`
    `protected void` | `execute(Connection connection, OperationObserver callback, SQLStatement compiled, Collection<Number> updateCounts)`
    `protected String` | `extractTemplateString()` Extracts a template string from a SQLTemplate query.
    `DbAdapter` | `getAdapter()` Returns unwrapped DbAdapter used to find correct SQL for a given DB.
    `protected int` | `getFetchOffset()`
    `SQLTemplate` | `getQuery()` Returns a SQLTemplate for this action.
    `void` | `performAction(Connection connection, OperationObserver callback)` Runs a SQLTemplate query, collecting all results.
    `protected void` | `processSelectResult(SQLStatement compiled, Connection connection, Statement statement, ResultSet resultSet, OperationObserver callback, long startTime)`

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### query

          protected SQLTemplate query

    - #### queryMetadata

          protected QueryMetadata queryMetadata

    - #### dbEntity

          protected DbEntity dbEntity

    - #### dataNode

          protected DataNode dataNode

    - #### dbAdapter

          protected DbAdapter dbAdapter

  - ### Constructor Detail

    - #### SQLTemplateAction

          public SQLTemplateAction(SQLTemplate query,
                                   DataNode dataNode)

      Since:
        4.0

  - ### Method Detail

    - #### getAdapter

          public DbAdapter getAdapter()

      Returns unwrapped DbAdapter used to find correct SQL for a given DB.

    - #### performAction

          public void performAction(Connection connection,
                                    OperationObserver callback)
                             throws SQLException,
                                    Exception

      Runs a SQLTemplate query, collecting all results. If a callback expects an iterated result, result processing is stopped after the first ResultSet is encountered.
      Specified by:
        `performAction` in interface `SQLAction`
      Throws:
        `SQLException`
        `Exception`

    - #### execute

          protected void execute(Connection connection,
                                 OperationObserver callback,
                                 SQLStatement compiled,
                                 Collection<Number> updateCounts)
                          throws SQLException,
                                 Exception

      Throws:
        `SQLException`
        `Exception`

    - #### processSelectResult

          protected void processSelectResult(SQLStatement compiled,
                                             Connection connection,
                                             Statement statement,
                                             ResultSet resultSet,
                                             OperationObserver callback,
                                             long startTime)
                                      throws Exception

      Throws:
        `Exception`

    - #### configureRowDescriptorBuilder

          protected RowDescriptorBuilder configureRowDescriptorBuilder(SQLStatement compiled,
                                                                       ResultSet resultSet)
                                                                throws SQLException

      Throws:
        `SQLException`
      Since:
        3.0

    - #### extractTemplateString

          protected String extractTemplateString()

      Extracts a template string from a SQLTemplate query. Exists mainly for the benefit of subclasses that can customize returned template.
      Since:
        1.2

    - #### bind

          protected void bind(PreparedStatement preparedStatement,
                              ParameterBinding[] bindings)
                       throws SQLException,
                              Exception

      Binds parameters to the PreparedStatement.
      Throws:
        `SQLException`
        `Exception`

    - #### getQuery

          public SQLTemplate getQuery()

      Returns a SQLTemplate for this action.

    - #### getFetchOffset

          protected int getFetchOffset()

      Since:
        3.0

Copyright © 2001–2021 Apache Cayenne. All rights reserved.