System Transactions -- Dependant on throwing exceptions

System Transactions -- Dependant on throwing exceptions

Old forum URL: forums.lhotka.net/forums/t/1034.aspx


JustCoding posted on Saturday, August 26, 2006

I like using the declarative model for defining transactions. Just like the following line of code.

   <Transactional(TransactionalTypes.TransactionScope)>

It appears to me that it depends on throwing an error in the object to rollback the transaction. For instance I have an object hierarchy that is several levels deep. If the child object xx fails it must throw the exception to rollback the transaction.

My problem is that I am trying to define an execution state object to determine successfull completion of transaction across all objects so that in a large project we don't have to rewrite the handling of specific exceptions like the database going down. So, we are not throwing errors, we are setting an execution state that is implemented in most of our objects and the controller is using that object to determine whether to send out emails, etc.

Given this scenario, how can I trigger the transaction to rollback if I don't throw errors since I only trap them and set appropriate information in the execution state object?

Has anyone come accross this issue or a similiar issue?

RockfordLhotka replied on Sunday, August 27, 2006

I modeled the TransactionScope support in CSLA after Enterprise Services with autocomplete, as it is the simplest model. To do what you want, you'll have to use Manual transactions and create your own TransactionScope object in the root object so you can call commit or rollback as needed.

Copyright (c) Marimer LLC