CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondCore/ORA/src/Transaction.cc

Go to the documentation of this file.
00001 #include "CondCore/ORA/interface/Transaction.h"
00002 #include "DatabaseSession.h"
00003 
00004 ora::Transaction::Transaction(DatabaseSession& session):
00005   m_session( session ),
00006   m_localActive( false ){
00007 }
00008 
00009 ora::Transaction::~Transaction() {
00010 }
00011 
00012 bool ora::Transaction::start( bool readOnly ){
00013   bool started = false;
00014   if(!m_localActive){
00015     m_session.startTransaction( readOnly );
00016     m_localActive = true;
00017     started = true;
00018   }
00019   return started;
00020 }
00021 
00022 bool ora::Transaction::commit(){
00023   bool committed = false;
00024   if(m_localActive){
00025     m_session.commitTransaction();
00026     m_localActive = false;
00027     committed = true;
00028   }
00029   return committed;
00030 }
00031 
00032 bool ora::Transaction::rollback(){
00033   bool rolled = false;
00034   if(m_localActive){
00035     m_session.rollbackTransaction();
00036     m_localActive = false;
00037     rolled = true;
00038   }
00039   return rolled;
00040 }
00041 
00042 bool ora::Transaction::isActive( bool checkIfReadOnly ) const {
00043   if( !m_session.isConnected() ) return false;
00044   return m_session.isTransactionActive( checkIfReadOnly );
00045 }
00046