org.apache.cayenne.access.jdbc
Class SQLTemplateAction

java.lang.Object
  extended by org.apache.cayenne.access.jdbc.SQLTemplateAction
All Implemented Interfaces:
SQLAction

public class SQLTemplateAction
extends java.lang.Object
implements SQLAction

Implements a strategy for execution of SQLTemplates.

Since:
1.2 replaces SQLTemplateExecutionPlan

Field Summary
protected  JdbcAdapter adapter
           
protected  DbEntity dbEntity
           
protected  SQLTemplate query
           
protected  QueryMetadata queryMetadata
           
 
Constructor Summary
SQLTemplateAction(SQLTemplate query, JdbcAdapter adapter, EntityResolver entityResolver)
           
 
Method Summary
protected  void bind(java.sql.PreparedStatement preparedStatement, ParameterBinding[] bindings)
          Binds parameters to the PreparedStatement.
protected  RowDescriptorBuilder configureRowDescriptorBuilder(SQLStatement compiled, java.sql.ResultSet resultSet)
           
protected  void execute(java.sql.Connection connection, OperationObserver callback, SQLStatement compiled, java.util.Collection<java.lang.Number> updateCounts)
           
protected  java.lang.String extractTemplateString()
          Extracts a template string from a SQLTemplate query.
 DbAdapter getAdapter()
          Returns DbAdapter associated with this execution plan object.
protected  int getFetchOffset()
           
 SQLTemplate getQuery()
          Returns a SQLTemplate for this action.
 void performAction(java.sql.Connection connection, OperationObserver callback)
          Runs a SQLTemplate query, collecting all results.
protected  void processSelectResult(SQLStatement compiled, java.sql.Connection connection, java.sql.Statement statement, java.sql.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

adapter

protected JdbcAdapter adapter

query

protected SQLTemplate query

queryMetadata

protected QueryMetadata queryMetadata

dbEntity

protected DbEntity dbEntity
Constructor Detail

SQLTemplateAction

public SQLTemplateAction(SQLTemplate query,
                         JdbcAdapter adapter,
                         EntityResolver entityResolver)
Since:
3.0
Method Detail

getAdapter

public DbAdapter getAdapter()
Returns DbAdapter associated with this execution plan object.


performAction

public void performAction(java.sql.Connection connection,
                          OperationObserver callback)
                   throws java.sql.SQLException,
                          java.lang.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:
java.sql.SQLException
java.lang.Exception

execute

protected void execute(java.sql.Connection connection,
                       OperationObserver callback,
                       SQLStatement compiled,
                       java.util.Collection<java.lang.Number> updateCounts)
                throws java.sql.SQLException,
                       java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

processSelectResult

protected void processSelectResult(SQLStatement compiled,
                                   java.sql.Connection connection,
                                   java.sql.Statement statement,
                                   java.sql.ResultSet resultSet,
                                   OperationObserver callback,
                                   long startTime)
                            throws java.lang.Exception
Throws:
java.lang.Exception

configureRowDescriptorBuilder

protected RowDescriptorBuilder configureRowDescriptorBuilder(SQLStatement compiled,
                                                             java.sql.ResultSet resultSet)
                                                      throws java.sql.SQLException
Throws:
java.sql.SQLException
Since:
3.0

extractTemplateString

protected java.lang.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(java.sql.PreparedStatement preparedStatement,
                    ParameterBinding[] bindings)
             throws java.sql.SQLException,
                    java.lang.Exception
Binds parameters to the PreparedStatement.

Throws:
java.sql.SQLException
java.lang.Exception

getQuery

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


getFetchOffset

protected int getFetchOffset()
Since:
3.0


Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.