Hi,
I'm wondering how to implement several wwBusiness objects using SQL Transaction control.
I believe that the approach is using setsqlobject to assign the wwSql object that handle the transaction over several wwBusiness objects ?
Is there any example that I could take a look at ?
Regards
It works the same as it works with standard SQL connections: You create a transaction and leave it open for the duration of the operations you want to perfom and you Commit or Rollback at the end of the operation.
Just make sure that if you coordinate multiple business objects that they all use the same physical connection (using .SetSqlObject(this.oSql)
) by passing a shared SQL connection to each of the child business objects.
Personally I prefer working with composition though - building single business objects that manipulate dependencies internally (ie. Invoice controls Lineitems and perhaps customer in the same context).
+++ Rick ---
Rick,
Sometimes a business transaction could be very heavy to make single objects but I understand how to do it so far.
Really grateful for your advice.
Regards.
Yes, if you have heavily interrelated business logic then multiple bus objects makes sense. I just recommend avoiding putting every little thing into its own business object.
Keeping with the last example, I would combine Invoice-Lineitems into a single business object, and the customer on the invoice in a separate business object. The invoice would then co-ordinate the Customer bus object to get customer related data and operations. It's easy enough to do the key is to try and pass the same connection information down to the related business object.
+++ Rick ---