#include <DbScopedTransaction.h>
Public Member Functions | |
int | commit () |
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close to the threshold | |
DbScopedTransaction (cond::DbSession &session) | |
int | isActive () const |
current transaction is active | |
bool | isLocallyActive () const |
query if locally has been activated | |
bool | isReadOnly () const |
current transaction is readonly | |
bool | rollback () |
rollback transaction | |
int | start (bool readOnly=false) |
start transaction | |
~DbScopedTransaction () | |
Private Attributes | |
bool | m_locallyActive |
cond::DbSession & | m_session |
Definition at line 17 of file DbScopedTransaction.h.
DbScopedTransaction::DbScopedTransaction | ( | cond::DbSession & | session | ) | [explicit] |
Definition at line 6 of file DbScopedTransaction.cc.
: m_session(session),m_locallyActive(false){ }
DbScopedTransaction::~DbScopedTransaction | ( | ) |
Definition at line 10 of file DbScopedTransaction.cc.
{ if(m_locallyActive) { m_session.transaction().rollback(); } }
int DbScopedTransaction::commit | ( | ) |
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close to the threshold
Definition at line 23 of file DbScopedTransaction.cc.
References runTheMatrix::ret.
Referenced by cond::Logger::createLogDBIfNonExist(), TestFunct::CreateMetaTable(), TestFunct::DropItem(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), HcalO2OManager::getListOfPoolIovs(), HcalO2OManager::getListOfPoolTags(), TestFunct::GetMetadata(), cond::Logger::logFailedOperationNow(), cond::Logger::logOperationNow(), l1t::DataWriter::payloadToken(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), TestFunct::Read(), TestFunct::ReadAll(), l1t::DataWriter::readObject(), TestFunct::ReadWithIOV(), l1t::WriterProxyT< Record, Type >::save(), TestFunct::Write(), l1t::DataWriter::writeKeyList(), and TestFunct::WriteWithIOV().
{ if(!m_locallyActive) return -1; int ret = m_session.transaction().commit(); m_locallyActive = false; return ret; }
int DbScopedTransaction::isActive | ( | ) | const |
current transaction is active
Definition at line 41 of file DbScopedTransaction.cc.
{ return m_session.transaction().isActive(); }
bool DbScopedTransaction::isLocallyActive | ( | ) | const |
query if locally has been activated
Definition at line 37 of file DbScopedTransaction.cc.
{ return m_locallyActive; }
bool DbScopedTransaction::isReadOnly | ( | ) | const |
current transaction is readonly
Definition at line 45 of file DbScopedTransaction.cc.
{ return m_session.transaction().isReadOnly(); }
bool DbScopedTransaction::rollback | ( | ) |
rollback transaction
Definition at line 30 of file DbScopedTransaction.cc.
References runTheMatrix::ret.
{ if(!m_locallyActive) return false; bool ret = m_session.transaction().rollback(); m_locallyActive = false; return ret; }
int DbScopedTransaction::start | ( | bool | readOnly = false | ) |
start transaction
Definition at line 16 of file DbScopedTransaction.cc.
References runTheMatrix::ret.
Referenced by cond::Logger::createLogDBIfNonExist(), TestFunct::CreateMetaTable(), TestFunct::DropItem(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), HcalO2OManager::getListOfPoolIovs(), HcalO2OManager::getListOfPoolTags(), TestFunct::GetMetadata(), cond::Logger::logFailedOperationNow(), cond::Logger::logOperationNow(), l1t::DataWriter::payloadToken(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), TestFunct::Read(), TestFunct::ReadAll(), l1t::DataWriter::readObject(), TestFunct::ReadWithIOV(), l1t::WriterProxyT< Record, Type >::save(), TestFunct::Write(), l1t::DataWriter::writeKeyList(), and TestFunct::WriteWithIOV().
{ if(m_locallyActive) return -1; int ret = m_session.transaction().start( readOnly ); m_locallyActive = true; return ret; }
bool cond::DbScopedTransaction::m_locallyActive [private] |
Definition at line 36 of file DbScopedTransaction.h.
Definition at line 35 of file DbScopedTransaction.h.