Multiple Transaction Rollbacks / Commits

Posts   
 
    
rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 01-Dec-2007 20:08:04   

Hello,

1) After adapter.StartTransaction(..), the first Rollback or Commit encountered will prevent the adapter instance from being used again. Is this correct?

If the adapter is initialized with keepConnectionOpen = true, then multiple Commit and RollBack calls will work until adapter.Dispose() is reached. Is this correct?

2) Should this code only Rollback to after the Commit statement?

adapter.SaveEntity(..); // save #1 adapter.Commit(); adapter.SaveEntity(..); // save #2 try { something} catch { adapter.RollBack(); // does this only RollBack save #2?}

Posts: 254
Joined: 16-Nov-2006
# Posted on: 02-Dec-2007 00:20:21   

1) No the adapter can be used after this time. The connection will simply be re created for any new requests

Note CloseConnection should reallly be used rather than Dispose if KeepConnectionOpen is used.

2) No, because StartTransaction hasn't been called after the first commit, the RollBack call will simply return because there is no transaction to roll back

You can of course create save points and then roll back to those specific save points.

rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 04-Dec-2007 11:47:55   

MattAdamson wrote:

1) No the adapter can be used after this time. The connection will simply be re created for any new requests

Note CloseConnection should reallly be used rather than Dispose if KeepConnectionOpen is used.

2) No, because StartTransaction hasn't been called after the first commit, the RollBack call will simply return because there is no transaction to roll back

You can of course create save points and then roll back to those specific save points.

Thanks, these points are clear.

Regarding #1. If Connection Pooling is being used, the cost of re-opening a connection (KeepConnectionOpen = false) will be greatly reduced, correct?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 04-Dec-2007 14:39:23   

Correct. Taking a connection from a connection pool is just a few ms.

Frans Bouma | Lead developer LLBLGen Pro