Prepare the given Query object, applying cache settings and/or a
transaction timeout.

@param query the Query object to prepare
183555
protected void prepareQuery(org.hibernate.query.Query query) {
        if (cacheQueries) {
            query.setCacheable(true);
        }
        if (shouldPassReadOnlyToHibernate()) {
            query.setReadOnly(true);
        }
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
        if (sessionHolder != null && sessionHolder.hasTimeout()) {
            query.setTimeout(sessionHolder.getTimeToLiveInSeconds());
        }
    }
653270
public void setQuery(String query) {

        try {
            m_parameters.setQuery(CmsEncoder.decodeParameter(query));
        } catch (CmsIllegalArgumentException iae) {
            m_lastException = iae;
        }
        resetLastResult();
    }
559639
public function prepare($query)
    {
        $this->connect();
        $options = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];
        $isObject = $query instanceof Query;
        if ($isObject && $query->isBufferedResultsEnabled() === false) {
            $options = [];
        }
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query, $options);

        return new SqlserverStatement($statement, $this);
    }
402896
function run_search(query) {
      	 var cache_key = query + computeURL();
          //var cached_results = cache.get(cache_key);
          /*if (cached_results) {
              if ($.isFunction($(input).data("settings").onCachedResult)) {
                cached_results = $(input).data("settings").onCachedResult.call(hidden_input, cached_results);
              }
              populate_dropdown(query, cached_results);
          } else {*/
              // Are we doing an ajax search or local data search?
              if($(input).data("settings").url) {
                  var url = computeURL();
                  // Extract existing get params
                  var ajax_params = {};
                  ajax_params.data = {};
                  if(url.indexOf("?") > -1) {
                      var parts = url.split("?");
                      ajax_params.url = parts[0];

                      var param_array = parts[1].split("&");
                      $.each(param_array, function (index, value) {
                          var kv = value.split("=");
                          ajax_params.data[kv[0]] = kv[1];
                      });
                  } else {
                      ajax_params.url = url;
                  }

                  // Prepare the request
                  ajax_params.data[$(input).data("settings").queryParam] = query;
                  ajax_params.type = $(input).data("settings").method;
                  ajax_params.dataType = $(input).data("settings").contentType;
                  if ($(input).data("settings").crossDomain) {
                      ajax_params.dataType = "jsonp";
                  }

                  // exclude current tokens?
                  // send exclude list to the server, so it can also exclude existing tokens
                  if ($(input).data("settings").excludeCurrent) {
                      var currentTokens = $(input).data("tokenInputObject").getTokens();
                      var tokenList = $.map(currentTokens, function (el) {
                          if(typeof $(input).data("settings").tokenValue == 'function')
                              return $(input).data("settings").tokenValue.call(this, el);

                          return el[$(input).data("settings").tokenValue];
                      });

                      ajax_params.data[$(input).data("settings").excludeCurrentParameter] = tokenList.join($(input).data("settings").tokenDelimiter);
                  }

                  // Attach the success callback
                  ajax_params.success = function(results) {
                    cache.add(cache_key, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
                    if($.isFunction($(input).data("settings").onResult)) {
                        results = $(input).data("settings").onResult.call(hidden_input, results);
                    }

                    // only populate the dropdown if the results are associated with the active search query
                    if(input_box.val() === query) {
                        populate_dropdown(query, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
                    }
                  };

                  // Provide a beforeSend callback
                  if (settings.onSend) {
                    settings.onSend(ajax_params);
                  }

                  // Make the request
                  $.ajax(ajax_params);
              } else if($(input).data("settings").local_data) {
                  // Do the search through local data
                 var results = $.grep($(input).data("settings").local_data, function (row) {
                      return row[$(input).data("settings").propertyToSearch].toLowerCase().indexOf(query.toLowerCase()) > -1;
                  });

                  cache.add(cache_key, results);
                  if($.isFunction($(input).data("settings").onResult)) {
                      results = $(input).data("settings").onResult.call(hidden_input, results);
                  }
                  populate_dropdown(query, results);
              }
          //}
      }
70057
public int executeUpdate(final String query) throws SQLException {
        startTimer();
        try {
            if (queryResult != null) {
                queryResult.close();
            }
            warningsCleared = false;
            if(inputStream == null)
                queryResult = protocol.executeQuery(queryFactory.createQuery(query));
            else 
                queryResult = protocol.executeQuery(queryFactory.createQuery(query), inputStream);
            return (int) ((ModifyQueryResult) queryResult).getUpdateCount();
        } catch (QueryException e) {
            throw SQLExceptionMapper.get(e);
        }
        finally
        {
            stopTimer();
            if(inputStream != null)
            {
                try
                {
                    inputStream.close();
                }
                catch (IOException e)
                {
                }
                inputStream = null;
            }
        }
    }
172922
protected <T> void prepareCriteria(Query<T> jpaQuery) {
        if (cacheQueries) {
            jpaQuery.setCacheable(true);
        }
        if (shouldPassReadOnlyToHibernate()) {
            jpaQuery.setReadOnly(true);
        }
        SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
        if (sessionHolder != null && sessionHolder.hasTimeout()) {
            jpaQuery.setTimeout(sessionHolder.getTimeToLiveInSeconds());
        }
    }
464693
private function _doExecuteCached(Query $query)
    {
        if (null !== $resultCache = $this->documentManager->getResultCache()) {
            $item = $resultCache->getItem($this->cacheProfile->getCacheKey());

            if ($item->isHit()) {
                yield from $item->get();

                return;
            }
        }

        $resultSets = iterator_to_array($this->_doExecute($query));

        if (isset($item)) {
            $item->set($resultSets);
            $item->expiresAfter($this->cacheProfile->getTtl());
            $resultCache->save($item);
        }

        yield from $resultSets;
    }
410848
@Override
    public MarkLogicTupleQuery prepareTupleQuery(QueryLanguage queryLanguage, String queryString) throws RepositoryException, MalformedQueryException {
        return prepareTupleQuery(queryLanguage, queryString, null);
    }
501914
public FutureData<DataSiftResult> start(FutureData<PreparedHistoricsQuery> query) {
        if (query == null) {
            throw new IllegalArgumentException("A valid PreparedHistoricsQuery is required");
        }
        final FutureData<DataSiftResult> future = new FutureData<>();
        DataSiftResult h = new BaseDataSiftResult();

        FutureResponse<PreparedHistoricsQuery> r = new FutureResponse<PreparedHistoricsQuery>() {
            public void apply(PreparedHistoricsQuery data) {
                if (data.getId() == null || data.getId().isEmpty()) {
                    throw new IllegalArgumentException("A valid PreparedHistoricsQuery is required");
                }
                start(data.getId(), future);
            }
        };
        unwrapFuture(query, future, h, r);
        return future;
    }
598507
public EbeanQueryWrapper bindAndPrepare(EbeanQueryWrapper query) {
        Assert.notNull(query, "query must not be null!");
        return bindAndPrepare(query, parameters);
    }
65609
function prepare()
    {
        $this->query = null;
        $this->count = null;
        $this->items = null;
    }
719095
public function prepare($query, $pdo_params=[]){
    if(!$this->connection()) return false;
    return isset($this->queries[$query]) ? $this->queries[$query] : ($this->queries[$query] = $this->connection()->prepare($query, $pdo_params));
  }
295802
def setQuery( self, query ):
        
        self._query = query
        if ( not self.signalsBlocked() ):
            self.queryChanged.emit(query)
1265989
private PreparedStatement createPreparedStatement(String query, int fetchSize, Object... params) throws SQLException {
        PreparedStatement stat = connection.prepareStatement(query);
        stat.setFetchSize(fetchSize);
        for (int i = 0; i < params.length; i++) {
            stat.setObject(i + 1, params[i]);
        }
        return stat;
    }
1304723
public void setQuery( String query )
    {
        _parameters = null;

        if ( query == null || query.length() == 0 ) { return; }

        for ( StringTokenizer tok = new StringTokenizer( query, "&" ); tok.hasMoreElements(); )
        {
            String queryItem = tok.nextToken();

            if ( queryItem.startsWith( "amp;" ) )
            {
                queryItem = queryItem.substring( 4 );
            }

            int eq = queryItem.indexOf( '=' );
            if ( eq != -1 )
            {
                addParameter( queryItem.substring( 0, eq ) , queryItem.substring( eq + 1 ), true );
            }
            else
            {
                addParameter( queryItem, null, true );
            }
        }
    }
949743
public void delete(Query query) {
        Log.debug("Deleting by query %s", query);
        try {
            indexWriter.deleteDocuments(query);
        } catch (IOException e) {
            Log.error(e, "Error while deleting by query %s", query);
            throw new RuntimeException(e);
        }
    }
703355
private void updateCache(int index, QueryParameters params) {
        if (generatedCacheMap.containsKey(index) == true) {
            this.generatedCacheMap.put(index, params);
        } else {
            this.resultSetCacheMap.put(index, params);
        }
    }