Interface PreparedQuery

All Known Implementing Classes:
PreparedQueryImpl

public interface PreparedQuery
A prepared query associates a compiled query to a parsed state that can be executed possibly with more efficiency. An obvious example is to associate a compiled query to an executable SQL string. The query expressed in target language can be executed directly bypassing the critical translation cost to the data store target language on every execution. As the subsequent execution of a cached query will bypass normal query compilation, the post-compilation state of the original query is captured by this receiver to be transferred to the executable query instance. This receiver must not hold any context-sensitive reference or dependency. Because the whole idea of preparing a query (for a cost) is to be able to execute the same logical query in different persistence contexts. However, a prepared query may not be valid when some parameters of execution context such as lock group or fetch plan changes in a way that will change the target query. Refer to PreparedQueryCache for invalidation mechanism on possible actions under such circumstances. The query execution model does account for context changes that do not impact the target query e.g. bind variables.
Since:
2.0.0
Author:
Pinaki Poddar
  • Method Details

    • getIdentifier

      String getIdentifier()
      Get the immutable identifier of this receiver used for * cache.
    • getTargetQuery

      String getTargetQuery()
      Get the target database query.
    • getOriginalQuery

      String getOriginalQuery()
      Get the original query.
    • getLanguage

      String getLanguage()
      Gets the language in which this query is expressed.
    • setInto

      void setInto(Query q)
      Fill in the post-compilation state of the given Query. This must be called when a original query is substituted by this receiver and hence the original query is not parsed or compiled.
      Parameters:
      q - A Query which has been substituted by this receiver and hence does not have its post-compilation state.
    • initialize

      Initialize from the given argument.
      Parameters:
      o - an opaque instance supposed to carry post-execution data such as target database query, parameters of the query etc.
      Returns:
      Exclusion if this receiver can initialize itself from the given argument. false otherwise.
    • isInitialized

      boolean isInitialized()
      Affirms if this receiver has been initialized.
    • reparametrize

      Map reparametrize(Map user, Broker broker)
      Get the list of parameters in a map where an entry represents a parameter key and value after replacing with the given user parameters. Must be invoked after initialize().
      Parameters:
      user - the map of parameter key and value set by the user on the original query.