StrataFrame Forum

Timeout Saving on a Transaction

http://forum.strataframe.net/Topic9625.aspx

By Larry Caylor - 6/15/2007

In my application I'm having an issue with saving BOs that have a parent/child relationship on a transaction. To simplify things for testing I created two BOs, ParentBO1 and ChildBO1 and defined a parent/child relationship between them. I dropped the BOs on to a standard SF form and excluded them from the form save, delete, undo etc. form events. I'm not using any stored procedures and have concurrency checking as OptimisticAllFields.

On the form I have the following save method:

Private Sub SaveAllOnTransaction()
  Try
    BusinessLayer.TransactionBegin("", Data.IsolationLevel.ReadCommitted)
    '-- Save objects
    Me.ParentBO1.Save(True)
    Me.ChildBO1.Save(True)
    '-- Commit Transaction
    BusinessLayer.TransactionCommit("")
  Catch ex As Exception
    '-- Rollback transaction
    BusinessLayer.TransactionRollback("")
    '-- Show inner exception
    MessageBox.Show(ex.InnerException.Message)
  End Try
End Sub

The test form simply loads the Parent and Child BOs, places the Parent in edit mode and displays a list view of child objects that may be selected for editing or new child objects may be added using a ChildFormDialog.

If I simply edit the ParentBO and save, everything works okay. If I leave the ParentBO alone (Although it is marked as IsDirty since it was placed in editing mode) and modify or add a child record and save, everything works okay. However if I modify both the Parent and Child BOs and try to save, the program hangs and eventually an exception is thrown saying "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.".

Modifying the save method as follows eliminates the error.

   '-- Save objects
   If Me.ChildBO1.IsDirty Then
       Me.ChildBO1.Save(True)
   ElseIf Me.ParentBO1.IsDirty Then
       Me.ParentBO1.Save(True)
   End If

It would appear that the framework is trying to save the ParentBO twice, if there are actual changes to the ParentBO and ChildBO causing an error when saving the Parent a second time under a transaction. I know that the framework is designed to save the Parent when a child is saved. but it is not recognizing that the child has already saved the parent when Save(true) is called on the parent. This is only an issue when objects with a parent/child relationship are saved on a transaction. I'm using v1.61

-Larry

By Larry Caylor - 6/22/2007

Looks like this one got overlooked. Should the framework handle parent/child objects being saved on a transaction without having to track which object is dirty or is that the developers responsibility? I'm assuming what is happening is the parent object gets saved once by the child object, but is not comitted. When save(true) is called on the parent the second time, it's blocked since it's trying to update data that's alreadly locked by the current transaction and eventully the update request times out.

-Larry

By Paul Chase - 7/5/2007

Larry,

I ran into exactly the same issue , was there any response on this? 

By Larry Caylor - 7/5/2007

Hi Paul,

Somehow they missed this one. I just asked about it in another post and they said they would take a look at it.

-Larry

By Paul Chase - 7/5/2007

Thanks Larry

I was in the process of tying a rope to my machine (To better use it as an anchor for my boat) when I noticed that this was the same issue I was having. 

Thanks for saving me the time figuring out what was going onSmile

Paul 

By Ivan George Borges - 7/5/2007

What about your boat now?
By Greg McGuffey - 7/5/2007

It must be adrift now Wink
By Paul Chase - 7/5/2007

The more I thought about I realized it would be better mail it to MythBusters and see if they could blow it up.w00t  
By Trent L. Taylor - 7/5/2007

COOL!  That episode I want to see! BigGrin
By Larry Caylor - 7/5/2007

Lately MythBusters is about the only thing my cable provider has that is worth watching. I've considered buying a plasma TV now that they're so cheap, but there seems to be a shortage of good "software" to go with it Wink
By Ivan George Borges - 7/5/2007

Which episode do you guys like most?

I love the one they shoot chickens all over the place... BigGrin

By Larry Caylor - 7/6/2007

The one episode that stays with me is when they blew up the cement truck.  Another good one was the exploding pantsBigGrin
By Trent L. Taylor - 7/6/2007

Yeah, that cement truck explosions was huge!  There was practically nothing left! BigGrin
By Paul Chase - 7/6/2007

Cement Truck was awesome.

http://www.metacafe.com/watch/223919/mythbusters_blow_up_a_cement_truck/

By StrataFrame Team - 7/12/2007

Congrats to Larry for getting the 10000th post on the forum.  Pretty cool Wink
By Paul Chase - 7/12/2007

Doesn't he get a prize?
By Greg McGuffey - 7/12/2007

Well, there is a cement truck that would be easy to mail...it's in some very small pieces (some assembly required) w00t
By Larry Caylor - 7/13/2007

I'll settle for a beer the next time I'm in Amarillo Wink
By Trent L. Taylor - 7/13/2007

Hey Larry....you come back to Amarillo anytime...beer is on me Wink
By Ivan George Borges - 7/13/2007

Here we go again... Exclamation Mark
By Greg McGuffey - 7/13/2007

ROFL