﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Transactional saving</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 07:02:34 GMT</lastBuildDate><ttl>20</ttl><item><title>Transactional saving</title><link>http://forum.strataframe.net/FindPost11990.aspx</link><description>I have 3 business objects which I want to create records for and then save on a transaction.&amp;nbsp; So, I know how the documentation says to do this and I have the following code in place:&lt;BR&gt;&lt;BR&gt;TransactionBegin("", IsolationLevel.ReadCommitted)&lt;BR&gt;AblStmtHdr.Save(True)&lt;BR&gt;AblStmtDays.Save(True)&lt;BR&gt;AblStmtRate.Save(True)&lt;BR&gt;TransactionCommit("")&lt;BR&gt;&lt;BR&gt;The issue here is that it is not saving out to the database correctly.&amp;nbsp; I have the following values before the transaction is commited:&lt;BR&gt;&lt;BR&gt;AblStmtHdr.Count=1&lt;BR&gt;AblStmtDays.Count=29&lt;BR&gt;AblStmtRate.Count=3&lt;BR&gt;&lt;BR&gt;However, when I check the database after the commit on the transaction I have 3 records for AblStmtHdr, 6 records for AblStmtRate, and 29 for AblStmtDays.&amp;nbsp; It has tripled the entry for AblStmtHdr, doubled it for AblStmtRate, and done&amp;nbsp;a single entry for AblStmtDays (correctly).&amp;nbsp; These entries are created in a nested loop which is the only thing I can think of that could be affected anything here.&amp;nbsp; But, when I save them outside of a transaction they save correctly.&amp;nbsp; Is there anything I could be doing in code that is causing this behavior??&amp;nbsp; This code works correctly:&lt;BR&gt;&lt;BR&gt;AblStmtHdr.Save()&lt;BR&gt;AblStmtDays.Save()&lt;BR&gt;AblStmtRate.Save()&lt;BR&gt;&lt;BR&gt;</description><pubDate>Wed, 17 Oct 2007 23:02:17 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Transactional saving</title><link>http://forum.strataframe.net/FindPost12052.aspx</link><description>I ran into this issue a while back and have therefore tried to avoid using parent child relationships when I want to save objects on a transaction. If you only have one level, a parent and child, doing something like the following works well&lt;P&gt;'-- Save objects&lt;BR&gt;If Me.ChildBO.IsDirty Then&lt;BR&gt;'-- Saving the child&amp;nbsp;will cause the ParentBO to be saved&lt;BR&gt;&amp;nbsp;&amp;nbsp; Me.ChildBO.Save(True)&lt;BR&gt;ElseIf Me.ParentBO.IsDirty Then&lt;BR&gt;'-- Only the parent will be saved&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.ParentBO.Save(True)&lt;BR&gt;End&lt;/P&gt;&lt;P&gt;If you have more complex relationships (levels) things get ugly really fast. Hopefully the SF guys will get this fixed... maybe in 1.62:Whistling:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;P&gt;-Larry</description><pubDate>Wed, 17 Oct 2007 23:02:17 GMT</pubDate><dc:creator>Larry Caylor</dc:creator></item><item><title>RE: Transactional saving</title><link>http://forum.strataframe.net/FindPost12050.aspx</link><description>Hi,&lt;br&gt;
Try to call your ChildBO.Save() instead of ParentBO. SF BO will check and call ParentBO.Save() by itself. With this, you don't have to do save and restore your ChildBO's ParentBusinessObject.&lt;br&gt;
&lt;br&gt;
HTH</description><pubDate>Wed, 17 Oct 2007 20:00:10 GMT</pubDate><dc:creator>Chan</dc:creator></item><item><title>RE: Transactional saving</title><link>http://forum.strataframe.net/FindPost12044.aspx</link><description>Okay, I have changed my code to look like the following:&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&amp;nbsp; TransactionBegin(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;, IsolationLevel.ReadCommitted)&lt;BR&gt;&amp;nbsp; AblStmtRate.ParentBusinessObject = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; AblStmtDays.ParentBusinessObject = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT color=#1f5080 size=2&gt;.Save(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;True&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#1f5080&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; AblStmtDays.Save(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;True&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&amp;nbsp; AblStmtRate.Save(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;True&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&amp;nbsp; T&lt;/FONT&gt;&lt;FONT size=2&gt;ransactionCommit(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Catch&lt;/FONT&gt;&lt;FONT size=2&gt; ex &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; Exception&lt;BR&gt;&amp;nbsp; TransactionRollback(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Finally&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;AblStmtRate.ParentBusinessObject = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;AblStmtDays.ParentBusinessObject = AblStmtRate&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#3333bb&gt;It is now saving out the correct number of records, but the keys are not populating correctly for the parent/child relationships.&amp;nbsp; They are still the temporary values like -1, -2.&amp;nbsp; Usually these resolve after they are saved and the foreign key values are correctly set.&amp;nbsp; This is not happening in the above code.&amp;nbsp; Can you please tell me if I'm doing something incorrect here?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 17 Oct 2007 14:48:30 GMT</pubDate><dc:creator>Andria Jensen</dc:creator></item><item><title>RE: Transactional saving</title><link>http://forum.strataframe.net/FindPost12016.aspx</link><description>It's a known issue with the way that the business objects save their parent business objects.&amp;nbsp; Since a business object is still dirty until its transaction commits, the child business objects try to save their parents again.&amp;nbsp; So, as a workaround, set the ParentBusinessObject property on all of the business objects to nothing before you save them on the transaction, then set it back again after the saves (in the Finally if you have it all wrapped in a try/catch).</description><pubDate>Tue, 16 Oct 2007 08:57:50 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>