Class ExecutedQuery

java.lang.Object
ortus.boxlang.runtime.jdbc.ExecutedQuery
All Implemented Interfaces:
Serializable

public final class ExecutedQuery extends Object implements Serializable
This class represents a query that has been executed and contains the results of executing that query. It contains a reference to the PendingQuery that was executed to create this.
See Also:
  • Constructor Details

    • ExecutedQuery

      public ExecutedQuery(@NonNull Query results, @Nullable Object generatedKey)
      Constructor
      Parameters:
      results - The results of the query, i.e. the actual Query object.
      generatedKey - The generated key of the query, if any.
  • Method Details

    • fromPendingQuery

      public static ExecutedQuery fromPendingQuery(@NonNull PendingQuery pendingQuery, @NonNull Statement statement, long executionTime, boolean hasResults)
      Creates an ExecutedQuery instance from a PendingQuery instance and a JDBC Statement.
      Parameters:
      pendingQuery - The PendingQuery executed.
      statement - The Statement instance executed.
      executionTime - The execution time the query took.
      hasResults - Boolean flag from PreparedStatement.execute() designating if the execution returned any results.
    • getResults

      public @NonNull Query getResults()
      Returns the Query object of results of the query.
      Returns:
      A Query object of results.
    • getResultsAsArray

      public @NonNull Array getResultsAsArray()
      Returns an Array of Struct instances representing the Query results.
      Returns:
      An Array of Structs representing the Query
    • getResultsAsStruct

      public @NonNull IStruct getResultsAsStruct(@NonNull String key)
      Returns a Struct instance grouping the results by the given key.
      Parameters:
      key - The column to group the results by.
      Returns:
      A struct of String to Struct instances representing the Query results.
    • getRecordCount

      public int getRecordCount()
      Returns the total count of records returned by the query.
      Returns:
      The total count of records.
    • getQueryMeta

      public @NonNull IStruct getQueryMeta()
      Retrieve query metadata.

      The struct contains the following keys:

      • SQL: The SQL statement that was executed. (string)
      • SqlParameters: An ordered Array of queryparam values. (array)
      • ExecutionTime: Execution time for the SQL request. (numeric)
      • GENERATEDKEY: If the query was an INSERT with an identity or auto-increment value the value of that ID is placed in this variable.
      • Cached: If the query was cached. (boolean)
      • CacheProvider: The cache provider used to cache the query. (string)
      • CacheKey: The cache key used to store the query in the cache. (string)
      • CacheTimeout: The max time the query will be cached for. (timespan)
      • CacheLastAccessTimeout: Max time to wait for a cache to be accessed before it is considered stale and automatically removed from the BoxLang cache. (timespan)
      Returns:
      A struct of query metadata, like original SQL, parameters, size, and cache info.
    • getGeneratedKey

      public @Nullable Object getGeneratedKey()
      Returns the generated key of the query, if any
      Returns:
      The generated key of the query.