User bio
404 bio not found
Member since May 26, 2022
Replies:

Hi Yaron, thanks for giving a test with the code example above. And the statement you referred is indeed from the documentation.

Yet to me the "transaction" mentioned is a bit ambiguous. I would rather interpret it as an explicit transaction demarcated by a TSTART and a TCOMMIT (or TROLLBACK) in the calling method.

Let me continue with your example here. This time I would like to add TSTART and TCOMMIT for the scope of the transaction, and there in the transaction I would like to add and save the second object:

USER>TSTART
USER>s obj=##class(USER.TestClass).%New(), obj.Name="Name", sc=obj.%Save() w !,sc
1
USER>zw ^USER.TestClassD
^USER.TestClassD=1
^USER.TestClassD(1)=$lb("","Name")
USER>s obj=##class(USER.TestClass).%New(), obj.Name="Name2", sc=obj.%Save() w !,sc
1
USER>zw ^USER.TestClassD
^USER.TestClassD=2
^USER.TestClassD(1)=$lb("","Name")
^USER.TestClassD(2)=$lb("","Name2")
USER>TCOMMIT

And what I really expect to see is, the %OnSaveFinally() method of those 2 objects will be called at the point just after TCOMMIT in my example, not after their own %Save() respectively.

Certifications & Credly badges:
Joseph has no Certifications & Credly badges yet.
Global Masters badges:
Joseph has no Global Masters badges yet.
Followers:
Joseph has no followers yet.
Following:
Joseph has not followed anybody yet.