Class PendingQuery

java.lang.Object
ortus.boxlang.runtime.jdbc.PendingQuery

public class PendingQuery extends Object
This class represents a query and any parameters/bindings before being executed. After calling execute(ConnectionManager,IBoxContext), it returns an ExecutedQuery with a reference to this object.
  • Field Details

  • Constructor Details

    • PendingQuery

      public PendingQuery(IBoxContext context, @NonNull String sql, Object bindings, QueryOptions queryOptions)
      Creates a new PendingQuery instance from a SQL string, a list of parameters, and the original SQL string.
      Parameters:
      context - The context that initiated this query.
      sql - The SQL string to execute
      bindings - An array or struct of QueryParameter to use as bindings.
      queryOptions - QueryOptions object denoting the options for this query.
    • PendingQuery

      public PendingQuery(IBoxContext context, @NonNull String sql, @NonNull List<QueryParameter> parameters)
      Creates a new PendingQuery instance from a SQL string and a list of parameters. This constructor uses the provided SQL string as the original SQL.
      Parameters:
      context - The context that initiated this query.
      sql - The SQL string to execute
      parameters - A list of QueryParameter to use as bindings.
  • Method Details

    • getDataSource

      public DataSource getDataSource()
      Get the datasource used to execute this query.
      Returns:
      The datasource used to execute this query.
    • getCacheKey

      public String getCacheKey()
      Retrieve the generated or provided-in-query-options cache key for this query.
    • getOriginalSql

      public @NonNull String getOriginalSql()
      Returns the original sql for this PendingQuery
      Returns:
      The original sql string
    • getSQLWithParamValues

      public @NonNull String getSQLWithParamValues()
      Return final SQL with paramter values
      Returns:
    • getParameterValues

      public @NonNull List<Object> getParameterValues()
      Returns a list of parameter `Object` values from the `List`. If a parameter is a list type, its values are expanded into the main list.
      Returns:
      A list of parameter values as `Object`s.
    • execute

      public @NonNull ExecutedQuery execute(ConnectionManager connectionManager, IBoxContext context)
      Executes the PendingQuery using the provided ConnectionManager and returns the results in an ExecutedQuery instance.
      Parameters:
      connectionManager - The ConnectionManager instance to use for getting connections from the current context.
      Returns:
      An ExecutedQuery instance with the results of this JDBC execution, as well as a link to this PendingQuery instance.
      Throws:
      DatabaseException - If a SQLException occurs, wraps it in a DatabaseException and throws.
      See Also:
    • execute

      public @NonNull ExecutedQuery execute(BoxConnection connection, IBoxContext context)
      Executes the PendingQuery on a given Connection and returns the results in an ExecutedQuery instance.
      Parameters:
      connection - The Connection instance to use for executing the query. It is the responsibility of the caller to close the connection after this method returns.
      Returns:
      An ExecutedQuery instance with the results of this JDBC execution, as well as a link to this PendingQuery instance.
      Throws:
      DatabaseException - If a SQLException occurs, wraps it in a DatabaseException and throws.
      See Also:
    • execute

      @Deprecated public @NonNull ExecutedQuery execute(Connection connection, IBoxContext context)
      Deprecated.
      Executes the PendingQuery on a given Connection and returns the results in an ExecutedQuery instance.
      Parameters:
      connection - The Connection instance to use for executing the query. It is the responsibility of the caller to close the connection after this method returns.
      Returns:
      An ExecutedQuery instance with the results of this JDBC execution, as well as a link to this PendingQuery instance.
      Throws:
      DatabaseException - If a SQLException occurs, wraps it in a DatabaseException and throws.
      See Also: