/*
(non-Javadoc)

@see com.impetus.client.cassandra.CassandraClientBase#execute(java.lang.String , java.lang.Object)
8399
@Override
    public <T> T execute(final String query, Object connection) {

        Session session = factory.getConnection();
        try {
            Statement queryStmt = new SimpleStatement(query);
            KunderaCoreUtils.printQuery(query, showQuery);
            queryStmt.setConsistencyLevel(ConsistencyLevel.valueOf(this.consistencyLevel.name()));
            return (T) session.execute(queryStmt);
        } catch (Exception e) {
            log.error("Error while executing query {}.", query);
            throw new KunderaException(e);
        } finally {
            // factory.releaseConnection(session);
        }
    }
998534
public T execute(HyperionClient client)
    {
        EntityList<T> entityResponse = client.update(build());
        List<T> entries = entityResponse.getEntries();
        return entries.size() == 0 ? null : entries.get(0);
    }
1042003
@Override
    public QueryResult execute( String query,
                                String language ) throws RepositoryException {
        logger.trace("Executing query: {0}", query);

        // Create the query ...

        final Query jcrQuery = getLocalSession().getSession().getWorkspace().getQueryManager().createQuery(query, language);
        return jcrQuery.execute();
    }
433843
@Override
    public void execute() {
        Set<String> annotated = db.getAnnotationIndex().get(Audit.class.getName());
        ScanAnnotatedFilter filter = new ScanAnnotatedFilter();
        for (String annotaionClass : annotated) {
            try {
                Class<?> clazz = Class.forName(annotaionClass);
                filter.addClass(clazz);
            } catch (ClassNotFoundException e) {
                throw new InitializationException("", e);
            }
        }
        PreConfigurationContext.addAnnotationFilter(filter);
    }
54572
public void execute() {
        // We can assume we have the named persistence unit and its mapping file in our classpath,
        // but we may have to allow some properties in that persistence unit to be overridden before
        // we can successfully get that persistence unit's metamodel.
        Map<String, String> properties = (configuration != null) ? configuration.getProperties() : null;
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName, properties);

        // Now we can get the persistence unit's metamodel and export it to Querydsl query types.
        Metamodel configuration = emf.getMetamodel();
        JPADomainExporter exporter = new JPADomainExporter(namePrefix, nameSuffix, new File(targetFolder), configuration);
        try {
            exporter.execute();
            generatedFiles = exporter.getGeneratedFiles();
        } catch (IOException e) {
            throw new RuntimeException("Error in JPADomainExporter", e);
        }
    }
495382
@Override
    public int executeBatch()
    {
        List<JsonObject> objectsToPersist = new ArrayList<JsonObject>();
        HttpResponse response = null;
        String databaseName = null;
        boolean isbulk = false;
        try
        {
            for (Node node : nodes)
            {
                if (node.isDirty())
                {
                    node.handlePreEvent();
                    // delete can not be executed in batch
                    if (node.isInState(RemovedState.class))
                    {
                        delete(node.getData(), node.getEntityId());
                    }
                    else
                    {
                        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                node.getDataClass());
                        databaseName = metadata.getSchema();
                        JsonObject asJsonObject = CouchDBObjectMapper.getJsonOfEntity(metadata, node.getData(),
                                node.getEntityId(), getRelationHolders(node), kunderaMetadata);
                        objectsToPersist.add(asJsonObject);
                        isbulk = true;
                    }
                    node.handlePostEvent();
                }
            }

            if (isbulk)
            {
                try
                {
                    URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                            CouchDBConstants.URL_SEPARATOR + databaseName.toLowerCase()
                                    + CouchDBConstants.URL_SEPARATOR + "_bulk_docs", null, null);

                    HttpPost post = new HttpPost(uri);
                    String object = String.format("{%s%s}", "\"all_or_nothing\": true,",
                            "\"docs\": " + gson.toJson(objectsToPersist));
                    StringEntity entity = new StringEntity(object, "UTF-8");
                    entity.setContentType("application/json");
                    post.setEntity(entity);
                    response = httpClient.execute(httpHost, post, CouchDBUtils.getContext(httpHost));
                }
                catch (Exception e)
                {
                    log.error("Error while executing batch, caused by {}. ", e);
                    throw new KunderaException("Error while executing batch. caused by :" + e);
                }
            }
        }
        catch (OperationNotSupportedException e)
        {
            throw new KunderaException(e.getMessage());
        }
        finally
        {
            CouchDBUtils.closeContent(response);
        }

        return nodes.size();
    }
781312
@Override
    <Result> String execute(final Callable<Result> callable,
                            final TaskCallback<Result> callback,
                            final Object caller) {
        checkArguments(callable, caller);
        return execute(TaskBuilder.create(callable).with(caller).
                callback(callback).on(this).done());
    }
1047928
public int execute(String sql, Object... params) {
        Connection conn = getConn();
        try {
            return conn.createQuery(sql)
                    .withParams(params)
                    .executeUpdate()
                    .getResult();
        } finally {
            this.closeConn(conn);
            this.clean(conn);
        }
    }
160020
Map<String,Object> executeEvent(Transaction trans, Map<String,Object> args, StringBuilder statementHolder) throws PersistenceException {
        logger.debug("enter - execute(Transaction, Map)");
        state = "EXECUTING";
        try {
            if( logger.isDebugEnabled() ) {
                logger.debug("Getting connection from transaction: " + trans.getTransactionId());
            }
            connection = trans.getConnection();
            data = args;
            try {
                String sql = loadStatement(connection, args);
                Map<String,Object> res;
                
                if( logger.isDebugEnabled() ) {
                    logger.debug("Preparing: " + sql);
                }
                if( statementHolder != null ) {
                    statementHolder.append(sql);
                }
                statement = connection.prepareStatement(sql);
                try {
                    logger.debug("And executing the prepared statement.");
                
                    res = run(trans, args);
                }
                finally {
                    try { statement.close(); statement = null; }
                    catch( Throwable ignore ) { }
                }
                if( logger.isDebugEnabled() ) {
                    logger.debug("RESULTS: " + res);
                }
                if( res ==  null ) {
                    return null;
                }
                else if( res instanceof HashMap ) {
                    return (HashMap<String,Object>)res;
                }
                else {
                    HashMap<String,Object> tmp = new HashMap<String,Object>();
                    
                    tmp.putAll(res);
                    return tmp;
                }
            }
            catch( SQLException e ) {
                logger.debug("Error executing event: " + e.getMessage(), e);
                throw new PersistenceException(e.getMessage());
            }
        }
        finally {
            state = "IDLE";
            logger.debug("exit - execute(Transaction, Map)");
        }
    }
677002
public void execute() throws Exception {
        ActionRequest request = requestBuilder.request();

        //todo: maby change to instanceof multi?
        if(requestBuilder instanceof JoinRequestBuilder){
            executeJoinRequestAndSendResponse();
        }
		else if (request instanceof SearchRequest) {
			client.search((SearchRequest) request, new RestStatusToXContentListener<SearchResponse>(channel));
		} else if (requestBuilder instanceof SqlElasticDeleteByQueryRequestBuilder) {
            throw new UnsupportedOperationException("currently not support delete on elastic 2.0.0");
        }
        else if(request instanceof GetIndexRequest) {
            this.requestBuilder.getBuilder().execute( new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
        }


		else {
			throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));
		}
	}
775064
@Override
    public boolean execute() throws SQLException {
        boolean isOk = false;

        try {
            boolean result = internalStmt.execute();
            isOk = true;

            return result;
        } finally {
            poolableConn.updateLastSQLExecutionTime(isOk);
        }
    }
1315549
public void execute(ChannelQueryListener listener) {
		addChannelQueryListener(listener);
		
		// Make a local copy to avoid synchronization
		Result localResult = result;
		
		// If the query was executed, just call the listener
		if (localResult != null) {
			listener.queryExecuted(localResult);
		} else {
			execute();
		}
		
	}
488235
private void executeSql(final Connection connection, final String sql, final boolean isCommit) throws SQLException
   {
      if (sql != null) {
         try (Statement statement = connection.createStatement()) {
            // connection was created a few milliseconds before, so set query timeout is omitted (we assume it will succeed)
            statement.execute(sql);
         }

         if (isIsolateInternalQueries && !isAutoCommit) {
            if (isCommit) {
               connection.commit();
            }
            else {
               connection.rollback();
            }
         }
      }
   }
104529
@Override
    public CompletableFuture<RootExecutionResultNode> execute(ExecutionContext context, FieldSubSelection fieldSubSelection) {
        return resolveSubSelection(context, fieldSubSelection)
                .thenApply(RootExecutionResultNode::new);
    }
1340988
private void executeScript(String script) {
        try {
            final StatementSplitter statementSplitter =
                new StatementSplitterResolver(scriptConfigurationInstance.get()).resolve();
            final ScriptExecutor scriptExecutor =
                new ScriptExecutor(databaseConnection.get().getConnection(), scriptConfigurationInstance.get(),
                    statementSplitter);
            scriptExecutor.execute(script);
        } catch (SQLException e) {
            throw new DBUnitConnectionException("Unable to execute script.", e);
        }
    }
626708
public void execute(DelegateExecution execution) {
    boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(execution, skipExpression);
    if (!isSkipExpressionEnabled || (isSkipExpressionEnabled && !SkipExpressionUtil.shouldSkipFlowElement(execution, skipExpression))) {

      if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {
        ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId());
        if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME)) {
          String overrideClassName = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_CLASS_NAME).asText();
          if (StringUtils.isNotEmpty(overrideClassName) && !overrideClassName.equals(className)) {
            className = overrideClassName;
            activityBehaviorInstance = null;
          }
        }
      }
      
      if (activityBehaviorInstance == null) {
        activityBehaviorInstance = getActivityBehaviorInstance();
      }

      try {
        activityBehaviorInstance.execute(execution);
      } catch (BpmnError error) {
        ErrorPropagation.propagateError(error, execution);
      } catch (RuntimeException e) {
        if (!ErrorPropagation.mapException(e, (ExecutionEntity) execution, mapExceptions))
          throw e;
      }
    }
  }
740599
@Override
  public final void executeQuery(final String pQuery) throws Exception {
    try {
      if (getLogger().getIsShowDebugMessagesFor(getClass())
        && getLogger().getDetailLevel() > 30000) {
        getLogger().debug(null, SrvDatabase.class, "try to execute query: "
          + pQuery);
      }
      this.sqliteDatabase.execSQL(pQuery);
    } catch (Exception ex) {
      String msg = ex.getMessage() + ", query:\n" + pQuery;
      ExceptionWithCode ewc = new ExceptionWithCode(SrvDatabase.SQL_EXEC_ERROR,
        msg);
      ewc.setStackTrace(ex.getStackTrace());
      throw ewc;
    }
  }