46
46
* Constructor that provides a database upon which to act
47
47
* @param database a database
49
explicit basic_transaction(
50
50
database &database );
52
virtual ~transaction() throw( );
57
* Constructor that provides a way for deriving classes to override the SQL
58
* executed in beginning and rolling-back a transaction during construction
60
* @param database a database
61
* @param begin_sql the SQL statement used to begin the transaction
62
* @param rollback_sql the SQL statement used to rollback the transaction,
63
* or an empty string if the default is to be used.
67
const std::string &begin_sql,
68
const std::string &rollback_sql = "" );
70
52
//______________________________________________________________________________
71
53
// public interface
57
* Begin the transaction
74
62
* Commit the transaction
79
67
* Rollback the transaction
69
virtual void rollback();
83
71
//______________________________________________________________________________
75
/* the database on which to act */
88
76
database &_database;
90
/** the SQL used to rollback the transaction, or empty to use default */
91
std::string _rollback_sql;
99
84
class exclusive_transaction
103
//______________________________________________________________________________
108
* Constructor that provides a database upon which to act
109
* @param database a database
111
exclusive_transaction(
112
database &database );
86
public basic_transaction
88
//______________________________________________________________________________
93
* Constructor that provides a database upon which to act
94
* @param database a database
96
explicit exclusive_transaction(
99
//______________________________________________________________________________
104
* Begin the transaction
106
virtual void begin();
111
////////////////////////////////////////////////////////////////////////////////
114
class recursive_transaction
116
public basic_transaction
118
//______________________________________________________________________________
123
* Constructor that provides a database upon which to act
124
* @param database a database
126
explicit recursive_transaction(
127
database &database );
129
//______________________________________________________________________________
134
* Begin the transaction
136
virtual void begin();
139
* Commit the transaction
141
virtual void commit();
144
* Rollback the transaction
146
virtual void rollback();
148
//______________________________________________________________________________
152
/* this transaction's savepoint name */
153
std::string _sp_name;
158
////////////////////////////////////////////////////////////////////////////////
161
template< class T = basic_transaction >
162
class transaction_guard
164
private boost::noncopyable
166
//______________________________________________________________________________
171
* Constructor that provides a database upon which to act
172
* @param database a database
174
explicit transaction_guard(
177
_transaction( database ),
180
_transaction.begin();
186
_transaction.rollback();
189
//______________________________________________________________________________
194
* Commit the transaction
199
_transaction.commit();
204
//______________________________________________________________________________
208
/* the transaction */
211
/* have we released the transaction yet? */