Transaction between Business Objects


Author
Message
Milton Abe
Milton Abe
StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)
Group: Forum Members
Posts: 5, Visits: 51
Hello! Say that you have two tables and for each table you have a Business Object. What If I want to put both tables in a transaction? Is there a way to control this (Transaction between these 2 BO's), or should I control transactions on stored procedures in one custom method in one of the BO's?

Thank you!

Peter Jones
Peter Jones
Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Milton,



My view is that if a transaction can be done in the database then that is best place it. I'm a great fan of SF but, when it comes to something like a transaction, I just think the database is the safer and more efficient alternative. Although, I have to say, this view has meant that I have never looked at the transaction facilities in SF in any detail.



Cheers, Peter
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Peter has a good approach, but really SF gives you more ultimate control on saving. So you will, in this particular case, want to create a transaction with a key and then use the same key for both saves. When you call the Save method of a BO, you can provide the transaction key, which means that you can choose which BOs to save on a tran and which to save off of a tran. So in this example, you would call the Save method on the BOs and supply the same transaction for both:



BusinessLayer.TransactionBegin("MyTranKey", Data.IsolationLevel.ReadCommitted);



MyBO1.Save(True, "MyTranKey");

MyBO2.Save(True, "MyTranKey");



BusinessLayer.TransactionCommit("MyTranKey");

Milton Abe
Milton Abe
StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)StrataFrame Beginner (7 reputation)
Group: Forum Members
Posts: 5, Visits: 51
In other words you still think that SF might has a better approach than transactions in DB? Or is there any particular case that you would recommend transactions in DB?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The only time that I ever recommend wrapping up transactions in the DB is when all INSERT logic, etc. will be server side, otherwise doing the transaction on the DB is more work and requires more code client side if this isn't the case. So yes, I would recommend doing this within the BO since this logic is tied into the BO.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search