Transactions, where to start them

Posts   
 
    
exp2000
User
Posts: 68
Joined: 13-Apr-2006
# Posted on: 27-Apr-2006 21:12:30   

I am little unclear where and how to start transactions. Maybe somebody can shed some light. If I use Manager class to manage business processes then I can star transaction in manager, and pass adapters to entity specific managers and then roll or commit. That is simple.

ProcessManager.dosomething { adapter= getAdapter adapter.start transaction entitymanager1.persist(entity,adapter) entitymanager2.delete(entity,adapter) end transaction }

How do I start transaction in UI without exposing adapter to the UI. Is it possible. Does it make sense?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 28-Apr-2006 02:58:20   

I believe that you would want to try to take care of these operations from the manager class without having the page handle the transaction. You should be able to keep the adapter out of your UI and be able to just use the classes available in the DatabaseGeneric project. So it would seem to me if you have an operation that spans the need for a transaction that it is handled in the manager classes. This is not a requirement by any means, just the way that I work with the adapter scenario.

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 29-Apr-2006 09:22:20   

I am not sure why you would want to code transactions into your UI, but couldnt you create an instance of a transaction and pass it to a manager class that forwarded the same transaction to the adapter? Isnt it also true, that the transaction wouldnt be committed or rolled back until the client committed or rolled it back?

I would think that it would be more practical for you to have your UI call a manager that wrapped access to a unit of work. Then have the UI call Commit on the manager, and then have the manager invoke the UOW2 commit.

So, OrderManager might have methods to AddCustomerToOrder, CreateNewOrder, AddProductToOrder, etc. These methods would internally add for update or add for save on a UnitOfWork. Then when the client was ready, they would call Manager.CommitOrder and woosh, all data gets saved.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 29-Apr-2006 17:36:19   

exp2000 Here is a link that might be useful http://msdn.microsoft.com/practices/topics/arch/default.aspx?pull=/library/en-us/dnbda/html/distapp.asp....its all about application architecture.