<mm:transaction> The transaction tag creates a transaction. A transaction is a group of actions that should be performed as a whole. If one of the things goes wrong, you can roll them back all.
see alsocommit | cancel
  • name
    The name of the transaction.
  • jspvar
    The name of the JSP variable to export.
  • commitonclose
    Whether the transaction must be committed after the body. The default is true.
contextwriter attributes
contextreferrer attributes
cloudreferrer attributes
cloudprovider attributes
example 1
<h3>Canceling transaction</h3>
<mm:transaction name="mytrans" commitonclose="false">
  <mm:createnode type="news">
    <mm:setfield name="title">Test node, created in transaction, canceled</mm:setfield>
    <mm:setfield name="subtitle"><mm:write referid="curtime" /></mm:setfield>
  <mm:cancel />
Transaction was canceled, following should not result anything:
<mm:listnodes id="l" type="news" constraints="subtitle = `$curtime'">
  <mm:field name="gui()" />
<br />
<h3>Committing transaction</h3>
<mm:transaction name="mytranz" jspvar="trans">
  jspvar of type Transaction:
    <%= trans instanceof org.mmbase.bridge.Transaction %><br />
  <mm:createnode type="news">
    <mm:setfield name="title">Test node, created in transaction, commited</mm:setfield>
    <mm:setfield name="subtitle"><mm:write referid="curtime" /></mm:setfield>
transaction was commited, following should result anything:
<mm:listnodes id="node" type="news" constraints="subtitle = `$curtime'" max="1">
  <mm:field name="html(subtitle)">
    <mm:compare referid2="curtime">
        YES (created node was <mm:field id="nodenumber" name="number" />)
        <mm:write referid="nodenumber" session="testnodenumber" />
        <mm:write referid="node" session="testnode" />
   <mm:field name="html(title)" />
<br />
<h3>Creating relation in transaction</h3>
<mm:transaction name="mytranc">
  <mm:node id="node1" number="$nodenumber" />
  <mm:createnode id="node2" type="news">
     <mm:setfield name="title">
        Test node2 with relation, created in transaction
     <mm:setfield name="subtitle"><mm:write referid="curtime" /></mm:setfield>
  <mm:createrelation source="node1" destination="node2" role="related" />