Package ortus.boxlang.runtime.jdbc
Class ExecutedQuery
java.lang.Object
ortus.boxlang.runtime.jdbc.ExecutedQuery
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionExecutedQuery(@NonNull Query results, @Nullable Object generatedKey) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutedQueryfromPendingQuery(@NonNull PendingQuery pendingQuery, @NonNull Statement statement, long executionTime, boolean hasResults) Creates an ExecutedQuery instance from a PendingQuery instance and a JDBC Statement.@Nullable ObjectReturns the generated key of the query, if any@NonNull IStructRetrieve query metadata.intReturns the total count of records returned by the query.@NonNull QueryReturns the Query object of results of the query.@NonNull Array@NonNull IStructgetResultsAsStruct(@NonNull String key) Returns aStructinstance grouping the results by the given key.
-
Constructor Details
-
ExecutedQuery
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- ThePendingQueryexecuted.statement- TheStatementinstance executed.executionTime- The execution time the query took.hasResults- Boolean flag fromPreparedStatement.execute()designating if the execution returned any results.
-
getResults
Returns the Query object of results of the query.- Returns:
- A Query object of results.
-
getResultsAsArray
- Returns:
- An Array of Structs representing the Query
-
getResultsAsStruct
Returns aStructinstance 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
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
Returns the generated key of the query, if any- Returns:
- The generated key of the query.
-