Poco::Data

template < class C >

class AbstractSessionImpl

Library: Data
Package: DataCore
Header: Poco/Data/AbstractSessionImpl.h

Description

A partial implementation of SessionImpl, providing features and properties management.

To implement a certain feature or property, a subclass must provide setter and getter methods and register them with addFeature() or addProperty().

Inheritance

Direct Base Classes: SessionImpl

All Base Classes: SessionImpl, Poco::RefCountedObject

Member Summary

Member Functions: addFeature, addProperty, getAutoCommit, getBulk, getEmptyStringIsNull, getFeature, getForceEmptyString, getHandle, getProperty, getSQLParse, getStorage, hasFeature, hasProperty, setAutoCommit, setBulk, setEmptyStringIsNull, setFeature, setForceEmptyString, setHandle, setProperty, setSQLParse, setStorage

Inherited Functions: begin, canTransact, close, commit, connectionString, connectorName, createStatementImpl, duplicate, getConnectionTimeout, getFeature, getLoginTimeout, getProperty, getTransactionIsolation, hasFeature, hasProperty, hasTransactionIsolation, isAutocommit, isConnected, isGood, isTransaction, isTransactionIsolation, open, reconnect, referenceCount, release, reset, rollback, setConnectionString, setConnectionTimeout, setFeature, setLoginTimeout, setProperty, setTransactionIsolation, shouldParse, uri

Types

Poco::Any

typedef Poco::Any (C::* PropertyGetter)(const std::string &)const;

The getter method for a property.

bool

typedef bool (C::* FeatureGetter)(const std::string &)const;

The getter method for a feature.

void

typedef void (C::* FeatureSetter)(const std::string &, bool);

The setter method for a feature.

void

typedef void (C::* PropertySetter)(const std::string &, const Poco::Any &);

The setter method for a property.

Constructors

AbstractSessionImpl inline

AbstractSessionImpl(
    const std::string & connectionString,
    std::size_t timeout = LOGIN_TIMEOUT_DEFAULT
);

Creates the AbstractSessionImpl.

Adds "storage" property and sets the default internal storage container type to std::deque. The storage is created by statements automatically whenever a query returning results is executed but external storage is provided by the user. Storage type can be reconfigured at runtime both globally (for the duration of the session) and locally (for a single statement execution only). See StatementImpl for details on how this property is used at runtime.

Adds "handle" property which, if set by the back end, returns native handle for the back end DB.

Adds "bulk" feature and sets it to false. Bulk feature determines whether the session is capable of bulk operations. Connectors that are capable of it must set this feature prior to attempting bulk operations.

Adds "emptyStringIsNull" feature and sets it to false. This feature should be set to true in order to modify the behavior of the databases that distinguish between zero-length character strings as nulls. Setting this feature to true shall disregard any difference between empty character strings and nulls, causing the framework to treat them the same (i.e. behave like Oracle).

Adds "forceEmptyString" feature and sets it to false. This feature should be set to true in order to force the databases that do not distinguish empty strings from nulls (e.g. Oracle) to always report empty string.

The "emptyStringIsNull" and "forceEmptyString" features are mutually exclusive. While these features can not both be true at the same time, they can both be false, resulting in default underlying database behavior.

Adds "sqlParse" feature and sets it to false; this property enables parsing of the SQL queries, to help the Data framework to determine whether to start a transaction automatically in non-autocomit mode (ie. not to start transaction if all the queries in an SQL statement are SELECTs). Note that the property is not a bullet-proof way to ensure this behavior, because not all SQL dialects are supported by the parser. When enabled, the parsing has performance cost, but it is otherwise non-intrusive, ie. on parse failure Statement only internally records parsing errors, but does not throw. See Poco::Data::Statement documentation for more information. This property has no effect when Poco::Data library is compiled with POCO_DATA_NO_SQL_PARSER.

Adds "autoCommit" feature and sets it to true. This property enables automatic commit. Setting this feature to true renders the sqlParse property meaningless, because every query is automatically commited.

Destructor

~AbstractSessionImpl virtual inline

~AbstractSessionImpl();

Destroys the AbstractSessionImpl.

Member Functions

getBulk inline

bool getBulk(
    const std::string & name = ""
) const;

Returns the execution type

getEmptyStringIsNull inline

bool getEmptyStringIsNull(
    const std::string & name = ""
) const;

Returns the setting for the behavior regarding empty variable length strings. See setEmptyStringIsNull(const std::string&, bool) and this class documentation for feature rationale and details.

getFeature virtual inline

bool getFeature(
    const std::string & name
) const;

Looks a feature up in the features map and calls the feature's getter, if there is one.

getForceEmptyString inline

bool getForceEmptyString(
    const std::string & name = ""
) const;

Returns the setting for the behavior regarding empty variable length strings. See setForceEmptyString(const std::string&, bool) and this class documentation for feature rationale and details.

getHandle inline

Poco::Any getHandle(
    const std::string & name = ""
) const;

Returns the native session handle.

getProperty virtual inline

Poco::Any getProperty(
    const std::string & name
) const;

Looks a property up in the properties map and calls the property's getter, if there is one.

getSQLParse inline

bool getSQLParse(
    const std::string & name = ""
) const;

Returns the value of the SQL parsing flag.

getStorage inline

Poco::Any getStorage(
    const std::string & name = ""
) const;

Returns the storage type

hasFeature virtual inline

bool hasFeature(
    const std::string & name
) const;

Looks a feature up in the features map and returns true if there is one.

hasProperty virtual inline

bool hasProperty(
    const std::string & name
) const;

Looks a property up in the properties map and returns true if there is one.

setBulk inline

void setBulk(
    const std::string & name,
    bool bulk
);

Sets the execution type.

setEmptyStringIsNull inline

void setEmptyStringIsNull(
    const std::string & name,
    bool emptyStringIsNull
);

Sets the behavior regarding empty variable length strings. Those are treated as NULL by Oracle and as empty string by most other databases. When this feature is true, empty strings are treated as NULL.

setFeature virtual inline

void setFeature(
    const std::string & name,
    bool state
);

Looks a feature up in the features map and calls the feature's setter, if there is one.

setForceEmptyString inline

void setForceEmptyString(
    const std::string & param91,
    bool forceEmptyString
);

Sets the behavior regarding empty variable length strings. Those are treated as NULL by Oracle and as empty string by most other databases. When this feature is true, both empty strings and NULL values are reported as empty strings.

setHandle inline

void setHandle(
    const std::string & name,
    const Poco::Any & handle
);

Sets the native session handle.

setProperty virtual inline

void setProperty(
    const std::string & name,
    const Poco::Any & value
);

Looks a property up in the properties map and calls the property's setter, if there is one.

setSQLParse inline

void setSQLParse(
    const std::string & param92,
    bool doParse
);

Enables the SQL parsing. Value must be of type bool. When SQL parsing is enabled (default), the Statement attempts to parse the SQL prior to executing it. The parsing is done in non-autocommit mode only, with purpose to determine the type of query and whether to start the transaction automatically.

See Statement documentation for more information.

setStorage inline

void setStorage(
    const std::string & value
);

Sets the storage type.

setStorage inline

void setStorage(
    const std::string & name,
    const Poco::Any & value
);

Sets the storage type.

addFeature protected inline

void addFeature(
    const std::string & name,
    FeatureSetter setter,
    FeatureGetter getter
);

Adds a feature to the map of supported features.

The setter or getter can be null, in case setting or getting a feature is not supported.

addProperty protected inline

void addProperty(
    const std::string & name,
    PropertySetter setter,
    PropertyGetter getter
);

Adds a property to the map of supported properties.

The setter or getter can be null, in case setting or getting a property is not supported.

getAutoCommit protected inline

bool getAutoCommit(
    const std::string & name = ""
) const;

Returns the value of the automatic commit flag. See setAutoCommit() documentation for more details.

setAutoCommit protected inline

void setAutoCommit(
    const std::string & param93,
    bool autoCommit
);

Enables automatic commit. When this feature is true, every query is automatically commited. When false, every query starts a transaction, except SELECT queries (if properly detected by parser, see set/getSQLParse() and Statement::checkBeginTransaction() documentation).