# Executor.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/orm/Executor.hpp"

# Executor

Database executor.

namespace oatpp { namespace orm { 
  class Executor {}
}}

# Methods

Return Type Name Summary
[none] Executor Default constructor.
[none] ~Executor Default virtual destructor.
std::shared_ptr<const data::mapping::TypeResolver> getDefaultTypeResolver Get default type resolver.
std::shared_ptr<data::mapping::TypeResolver> createTypeResolver Create new type resolver.
std::shared_ptr<Connection> getConnection Get database connection.
StringTemplate parseQueryTemplate Parse query template.
std::shared_ptr<QueryResult> execute Multiple implementations:
  1. Execute database query using a query template.
  2. Execute an arbitrary database query.
std::shared_ptr<QueryResult> begin Begin database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.
std::shared_ptr<QueryResult> commit Commit database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.
std::shared_ptr<QueryResult> rollback Rollback database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.
v_int64 getSchemaVersion Get current database schema version.
void migrateSchema Run schema migration script. Should NOT be used directly. Use oatpp::orm::SchemaMigration instead.

# Executor::Executor

Default constructor.

Executor()

# Executor::~Executor

Default virtual destructor.

virtual ~Executor() = default

# Executor::getDefaultTypeResolver

Get default type resolver.

  • @return

std::shared_ptr<const data::mapping::TypeResolver> getDefaultTypeResolver()

# Executor::createTypeResolver

Create new type resolver.

  • @return

virtual std::shared_ptr<data::mapping::TypeResolver> createTypeResolver() = 0

# Executor::getConnection

Get database connection.

  • @return

virtual std::shared_ptr<Connection> getConnection() = 0

# Executor::parseQueryTemplate

Parse query template.

  • @param name - template name.
  • @param text - template text.
  • @param paramsTypeMap - template parameter types.
  • @param prepare - true if the query should use prepared statement, false otherwise.
  • @return - oatpp::data::share::StringTemplate.

virtual StringTemplate parseQueryTemplate(const oatpp::String& name,
                                          const oatpp::String& text,
                                          const ParamsTypeMap& paramsTypeMap,
                                          bool prepare = false) = 0

# Executor::execute

  1. Execute database query using a query template.
    • @param queryTemplate - a query template obtained in a prior call to Executor::parseQueryTemplate() method.
    • @param params - query parameters.
    • @param enabledInterpretations - enabled type interpretations.
    • @param connection - database connection.
    • @return - oatpp::orm::QueryResult.
    virtual std::shared_ptr<QueryResult> execute(const StringTemplate& queryTemplate,
                                                 const std::unordered_map<oatpp::String, oatpp::Void>& params,
                                                 const std::shared_ptr<const data::mapping::TypeResolver>& typeResolver = nullptr,
                                                 const std::shared_ptr<Connection>& connection = nullptr) = 0
    
  2. Execute an arbitrary database query.
    In its default implementation it'll call execute with the null-named query template. The query template will be created by a call to parseQueryTemplate(nullptr, query, {}, false).
    • @param query - query text.
    • @param params - query parameters.
    • @param enabledInterpretations - enabled type interpretations.
    • @param connection - database connection.
    • @return - oatpp::orm::QueryResult.
    virtual std::shared_ptr<QueryResult> execute(const oatpp::String& query,
                                                 const std::unordered_map<oatpp::String, oatpp::Void>& params,
                                                 const std::shared_ptr<const data::mapping::TypeResolver>& typeResolver = nullptr,
                                                 const std::shared_ptr<Connection>& connection = nullptr)
    

# Executor::begin

Begin database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.

virtual std::shared_ptr<QueryResult> begin(const std::shared_ptr<Connection>& connection = nullptr) = 0

# Executor::commit

Commit database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.

virtual std::shared_ptr<QueryResult> commit(const std::shared_ptr<Connection>& connection) = 0

# Executor::rollback

Rollback database transaction. Should NOT be used directly. Use oatpp::orm::Transaction instead.

virtual std::shared_ptr<QueryResult> rollback(const std::shared_ptr<Connection>& connection) = 0

# Executor::getSchemaVersion

Get current database schema version.

  • @param suffix - suffix of schema version control table name.
  • @param connection - database connection.
  • @return - schema version.

virtual v_int64 getSchemaVersion(const oatpp::String& suffix = nullptr,
                                 const std::shared_ptr<Connection>& connection = nullptr) = 0

# Executor::migrateSchema

Run schema migration script. Should NOT be used directly. Use oatpp::orm::SchemaMigration instead.

  • @param script - script text.
  • @param newVersion - schema version corresponding to this script.
  • @param suffix - suffix of schema version control table name.
  • @param connection - database connection.

virtual void migrateSchema(const oatpp::String& script,
                           v_int64 newVersion,
                           const oatpp::String& suffix = nullptr,
                           const std::shared_ptr<Connection>& connection = nullptr) = 0