<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Transaction not committing in web script in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292500#M245630</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have written a web script that searches for a set of nodes of a particular type that were created in a specified date range, then deletes each node and recreates it with the same data (this is intended to fix a problem that is out of the scope of this question). The code that re-creates the node does a search first to confirm that the node does not exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have each delete and create enclosed in a transaction. When I run in the debugger and trace through the code, everything works because the deleted node is not found. If run without the debugger, the search for the existing node returns a result, with all the fields marked as "missing". Because the node already (incompletely) exists, the new node is not created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The web script definition has &amp;lt;transaction&amp;gt;none&amp;lt;/transaction&amp;gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some stripped-down code minus things like error handling, try/catch, rollbacks, etc.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UserTransaction trxDelete = serviceRegistry.getTransactionService().getNonPropagatingUserTransaction(false);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trxDelete.begin();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;retBi = deleteBundle(bundleId);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;trxDelete.commit();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UserTransaction trxCreate = serviceRegistry.getTransactionService().getNonPropagatingUserTransaction(false);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trxCreate.begin();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;retBi = createBundle(bundleId, bundleInfo.getBundledSubmissions());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;trxCreate.commit();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;createBundle() does the search on bundleId before creating the node, and is finding the deleted node IFF I don't run in the debugger. If run in the debugger, it doesn't find the deleted node. This makes me think that the commit is taking some time to actually complete and is returning before it's complete.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the best way to handle this situation?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jul 2015 16:35:54 GMT</pubDate>
    <dc:creator>billhole</dc:creator>
    <dc:date>2015-07-22T16:35:54Z</dc:date>
    <item>
      <title>Transaction not committing in web script</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292500#M245630</link>
      <description>I have written a web script that searches for a set of nodes of a particular type that were created in a specified date range, then deletes each node and recreates it with the same data (this is intended to fix a problem that is out of the scope of this question). The code that re-creates the node d</description>
      <pubDate>Wed, 22 Jul 2015 16:35:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292500#M245630</guid>
      <dc:creator>billhole</dc:creator>
      <dc:date>2015-07-22T16:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction not committing in web script</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292501#M245631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your code would seem to be O.K. but there's some devil in the detail.&amp;nbsp;&amp;nbsp; In particular you havn't said how your search within createBundle is working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be better if you could avoid the two transactions and the use of the raw transaction handling.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the bottom line is it should work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2015 17:12:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292501#M245631</guid>
      <dc:creator>mrogers</dc:creator>
      <dc:date>2015-07-22T17:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction not committing in web script</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292502#M245632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the validation of that code. I found an Alfresco programmer on another team and he has a logical theory. The search is using Lucene/Solr. He thinks the Solr index is refreshed outside of the transaction, so the search was fetching stale data. I wrote a simplified create function that creates the new node without first searching for it, and everything is working fine now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2015 19:42:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-not-committing-in-web-script/m-p/292502#M245632</guid>
      <dc:creator>billhole</dc:creator>
      <dc:date>2015-07-22T19:42:03Z</dc:date>
    </item>
  </channel>
</rss>

