CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DbTransaction.cc
Go to the documentation of this file.
1 // local includes
4 // coral & pool includes
5 #include "RelationalAccess/ISessionProxy.h"
6 #include "RelationalAccess/ITransaction.h"
7 
9  m_dbTrans( dbTrans ),m_readOnly(true),m_clients(0),m_owned(owned ){
10 }
11 
13  if( m_owned ) rollback();
14 }
15 
16 int cond::DbTransaction::start(bool readOnly){
17  if(!m_clients){
18  m_dbTrans.start( readOnly );
19  m_readOnly = readOnly;
20  } else {
21  if(readOnly != m_readOnly)
22  return -1;
23  }
24  ++m_clients;
25  return m_clients;
26 }
27 
29  if(!m_clients) return -1;
30  else{
31  --m_clients;
32  if(m_clients == 0){
33  m_dbTrans.commit();
34  }
35  }
36  return m_clients;
37 }
38 
40  bool doCommit = false;
41  if(m_clients){
42  m_dbTrans.commit();
43  doCommit = true;
44  }
45  m_clients = 0;
46  return doCommit;
47 }
48 
50  bool doRollBack = false;
51  if(m_clients){
52  m_dbTrans.rollback();
53  doRollBack = true;
54  }
55  m_clients = 0;
56  return doRollBack;
57 }
58 
60  if(!m_dbTrans.isActive()) return 0;
61  return m_clients;
62 }
63 
65 {
66  return m_dbTrans.isActive( true );
67 }
68 
bool rollback()
rollback transaction
int isActive() const
current transaction is active
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
bool forceCommit()
force the commit, regardless to the transaction clients
DbTransaction(ora::Transaction &dbTrans, bool owned=true)
Definition: DbTransaction.cc:8
bool isReadOnly() const
current transaction is readonly