#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 21 of file DbScopedTransaction.cc.
References runTheMatrix::ret.
Referenced by cond::service::PoolDBOutputService::add(), cond::service::PoolDBOutputService::closeIOV(), CondDBESSource::CondDBESSource(), cond::service::PoolDBOutputService::createNewIOV(), CondDBESSource::fillTagCollectionFromDB(), HcalO2OManager::getListOfPoolIovs(), HcalO2OManager::getListOfPoolTags(), cond::RDBMS::globalTag(), cond::service::PoolDBOutputService::initDB(), l1t::DataWriter::payloadToken(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), l1t::DataWriter::readObject(), cond::impl::IOVImpl::refresh(), l1t::WriterProxyT< Record, Type >::save(), and l1t::DataWriter::writeKeyList().
{ 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 39 of file DbScopedTransaction.cc.
Referenced by cond::impl::IOVImpl::refresh().
{ return m_session.transaction().isActive(); }
bool DbScopedTransaction::isLocallyActive | ( | ) | const |
query if locally has been activated
Definition at line 35 of file DbScopedTransaction.cc.
{ return m_locallyActive; }
bool DbScopedTransaction::isReadOnly | ( | ) | const |
current transaction is readonly
Definition at line 43 of file DbScopedTransaction.cc.
Referenced by cond::impl::IOVImpl::refresh().
{ /*if(m_locallyActive) */return m_session.transaction().isReadOnly(); //return true; }
bool DbScopedTransaction::rollback | ( | ) |
rollback transaction
Definition at line 28 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 14 of file DbScopedTransaction.cc.
References runTheMatrix::ret.
Referenced by cond::service::PoolDBOutputService::add(), cond::service::PoolDBOutputService::closeIOV(), CondDBESSource::CondDBESSource(), cond::service::PoolDBOutputService::createNewIOV(), CondDBESSource::fillTagCollectionFromDB(), HcalO2OManager::getListOfPoolIovs(), HcalO2OManager::getListOfPoolTags(), cond::RDBMS::globalTag(), cond::service::PoolDBOutputService::initDB(), l1t::DataWriter::payloadToken(), L1ConfigOnlineProdBase< TRcd, TData >::produce(), l1t::DataWriter::readObject(), cond::impl::IOVImpl::refresh(), l1t::WriterProxyT< Record, Type >::save(), and l1t::DataWriter::writeKeyList().
{ 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.