West Wind Internet and Client Tools
wwBusiness and SQL Transactions control
Gravatar is a globally recognized avatar based on your email address. wwBusiness and SQL Transactions control
  Julio Cesar Santone
  All
  Sep 18, 2017 @ 02:32pm

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

Gravatar is a globally recognized avatar based on your email address. re: wwBusiness and SQL Transactions control
  Rick Strahl
  Julio Cesar Santone
  Sep 18, 2017 @ 07:04pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: wwBusiness and SQL Transactions control
  Julio Cesar Santone
  Rick Strahl
  Sep 18, 2017 @ 07:10pm

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.

Gravatar is a globally recognized avatar based on your email address. re: wwBusiness and SQL Transactions control
  Rick Strahl
  Julio Cesar Santone
  Sep 19, 2017 @ 11:40am

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 ---

© 1996-2024