# 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
  Description
  `protected DataNode`
  `dataNode`
  `protected DbAdapter`
  `dbAdapter`
  `protected DbEntity`
  `dbEntity`
  `protected SQLTemplate`
  `query`
  `protected QueryMetadata`
  `queryMetadata`

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `bind(PreparedStatement preparedStatement, PSParameter[] bindings)`
  Binds parameters to the PreparedStatement.
  `protected void`
  `execute(Connection connection, OperationObserver callback, TranslatedSQL 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(TranslatedSQL compiled, Connection connection, Statement statement, ResultSet resultSet, OperationObserver callback, long startTime)`
  `protected RSColumn.RowBuilder`
  `rowBuilder(TranslatedSQL compiled, ResultSet resultSet)`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### query

    protected SQLTemplate query

  - ### queryMetadata

    protected QueryMetadata queryMetadata

  - ### dbEntity

    protected DbEntity dbEntity

  - ### dataNode

    protected DataNode dataNode

  - ### dbAdapter

    protected DbAdapter dbAdapter

- ## Constructor Details

  - ### SQLTemplateAction

    public SQLTemplateAction(SQLTemplate query, DataNode dataNode)
    Since:
      4.0

- ## Method Details

  - ### 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 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:
      `Exception`

  - ### execute

    protected void execute(Connection connection, OperationObserver callback, TranslatedSQL compiled, Collection<Number> updateCounts) throws Exception
    Throws:
      `Exception`

  - ### processSelectResult

    protected void processSelectResult(TranslatedSQL compiled, Connection connection, Statement statement, ResultSet resultSet, OperationObserver callback, long startTime) throws Exception
    Throws:
      `Exception`

  - ### rowBuilder

    protected RSColumn.RowBuilder rowBuilder(TranslatedSQL 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, PSParameter[] bindings) throws Exception
    Binds parameters to the PreparedStatement.
    Throws:
      `Exception`

  - ### getQuery

    public SQLTemplate getQuery()
    Returns a SQLTemplate for this action.

  - ### getFetchOffset

    protected int getFetchOffset()
    Since:
      3.0