Transaction clarification.

Posts   
 
    
netLearner
User
Posts: 150
Joined: 18-Oct-2003
# Posted on: 21-Mar-2005 21:34:39   

Hi Frans, I have 3 classes: Ex: Customer and CustomerEntity, and AnotherCustomer Customer maps to a different table and CustomerEntity maps to more than 1 table and differnt from Customer, AnotherCust maps to a diff table. I need to save 3 of them in 1 trans. CustomerEntity is Pro generated class. Customer and ANotherCust are not a Pro genrated class. So i am wondering what is the base way to save 3 of them in 1 trans. This is what i am doing: Create a SqlTrans object, set the conn string to it, open the conn, call begin trans, call Customer.SaveToDB(); call CustomeEntity.Save(true); call AnotherCust.SaveToDB(); commit.

What i am wondering is if for some reason AnotherCust.SaveToDB() fails will it rollback CustomerEntity.Save(true) ? Please let me know. Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Mar-2005 10:31:29   

How are these other classes saved? Using your own sql?

Frans Bouma | Lead developer LLBLGen Pro
netLearner
User
Posts: 150
Joined: 18-Oct-2003
# Posted on: 22-Mar-2005 15:07:48   

Yes they call stored procs of their own. Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Mar-2005 15:22:27   

netLearner wrote:

Yes they call stored procs of their own. Thanks

You should grab the Transaction.ConnectionToUse connection and use that connection to call the procedures. That way, the calls are in the same transaction and rolled back if you call Transaction.RollBack simple_smile

Frans Bouma | Lead developer LLBLGen Pro