this.translatedCommand = factory.translate(command);
RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
// Create the execution based on mode
final Execution exec = connector.createExecution(this.translatedCommand, this.securityContext, rmd, (unwrapped == null) ? this.connection:unwrapped);
if (this.translatedCommand instanceof Call) {
this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
StoredProcedure proc = (StoredProcedure)command;
if (proc.returnParameters()) {
this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)exec);
}
} else if (this.translatedCommand instanceof QueryExpression){
this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
} else {
Assertion.isInstanceOf(exec, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
this.execution = new ResultSetExecution() {
private int[] results;
private int index;
@Override
public void cancel() throws TranslatorException {
exec.cancel();
}
@Override
public void close() {
exec.close();
}
@Override
public void execute() throws TranslatorException {
exec.execute();
}
@Override
public List<?> next() throws TranslatorException,
DataNotAvailableException {
if (results == null) {