mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
@@ -25,9 +25,9 @@ namespace Data {
|
||||
|
||||
Session::Session(Poco::AutoPtr<SessionImpl> pImpl):
|
||||
_pImpl(pImpl),
|
||||
_statementCreator(pImpl)
|
||||
_statementCreator(pImpl),
|
||||
_wasAutoCommit(false)
|
||||
{
|
||||
poco_check_ptr (pImpl.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ Session::Session(const std::string& connector,
|
||||
}
|
||||
|
||||
|
||||
Session::Session(const std::string& connection,
|
||||
std::size_t timeout)
|
||||
Session::Session(const std::string& connection, std::size_t timeout)
|
||||
{
|
||||
Session newSession(SessionFactory::instance().create(connection, timeout));
|
||||
swap(newSession);
|
||||
@@ -50,14 +49,16 @@ Session::Session(const std::string& connection,
|
||||
|
||||
Session::Session(const Session& other):
|
||||
_pImpl(other._pImpl),
|
||||
_statementCreator(other._statementCreator)
|
||||
_statementCreator(other._statementCreator),
|
||||
_wasAutoCommit(other._wasAutoCommit)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Session::Session(Session&& other) noexcept:
|
||||
_pImpl(std::move(other._pImpl)),
|
||||
_statementCreator(std::move(other._statementCreator))
|
||||
_statementCreator(std::move(other._statementCreator)),
|
||||
_wasAutoCommit(other._wasAutoCommit)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,6 +79,7 @@ Session& Session::operator = (Session&& other) noexcept
|
||||
{
|
||||
_pImpl = std::move(other._pImpl);
|
||||
_statementCreator = std::move(other._statementCreator);
|
||||
_wasAutoCommit = other._wasAutoCommit;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -87,6 +89,40 @@ void Session::swap(Session& other)
|
||||
using std::swap;
|
||||
swap(_statementCreator, other._statementCreator);
|
||||
swap(_pImpl, other._pImpl);
|
||||
swap(_wasAutoCommit, other._wasAutoCommit);
|
||||
}
|
||||
|
||||
|
||||
void Session::begin()
|
||||
{
|
||||
if (isAutocommit())
|
||||
{
|
||||
setFeature("autoCommit", false);
|
||||
_wasAutoCommit = true;
|
||||
}
|
||||
return _pImpl->begin();
|
||||
}
|
||||
|
||||
|
||||
void Session::commit()
|
||||
{
|
||||
_pImpl->commit();
|
||||
if (_wasAutoCommit)
|
||||
{
|
||||
setFeature("autoCommit", true);
|
||||
_wasAutoCommit = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Session::rollback()
|
||||
{
|
||||
_pImpl->rollback();
|
||||
if (_wasAutoCommit)
|
||||
{
|
||||
setFeature("autoCommit", true);
|
||||
_wasAutoCommit = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user