4 ms·
This concept is almost the same as trx = new DbTransaction(); ... trx.commit() or trx.rollback(); It's easy to be missed, but it's hard to detect without ma
by revskill 4y ago
This concept is almost the same as
trx = new DbTransaction();
...
trx.commit() or trx.rollback();
It's easy to be missed, but it's hard to detect without manually remembering where to put it in the correct place.
- deathanatos 4y agoIt's the same concept. RAII can (and I have seen DB libraries that do) model a DB transaction as a resource. In the cases that I know of, they take the safe default of rolling the transaction back if the code fails to commit it. But the transaction is never leaked nor is the connection left in some unspecified state.