On Nov 12, 2009, at 12:49 AM, Cimballi wrote:

> Hi,
> 
> I have developed several custom services and I encounter a problem
> with transactions.
> My service is calling other services and I notice that when a first
> service successed, but a second failed, the data of the first service
> has not been rolled back.
> Example :
> - First, I call "createPersonAndUserLogin" using dispatcher.runSync
> - Second, I call "createPartyRole" using dispatcher.runSync
> 
> The second call failed because I didn't provide all parameters, but
> the party created in the first call is still there.

The reason is in the service definition for "createPersonAndUserLogin":

    <service name="createPersonAndUserLogin" engine="simple" 
require-new-transaction="true"
            
location="component://party/script/org/ofbiz/party/party/PartySimpleMethods.xml"
 invoke="createPersonAndUserLogin" auth="false">
        <description>Create a Person and UserLogin</description>
        <implements service="createUserLogin"/>
        <auto-attributes entity-name="Person" mode="IN" include="nonpk" 
optional="true"/>
        <auto-attributes entity-name="Party" mode="IN" include="nonpk" 
optional="true"/>
        <attribute name="partyId" type="String" mode="INOUT" optional="true" 
entity-name="Person"/>
        <attribute name="newUserLogin" type="Map" mode="OUT" optional="false"/>
    </service>

This service is executed in its own transaction because of the attribute:

require-new-transaction="true"

Jacopo

> 
> Is there a way to avoid this, to have a transaction covering all runSync 
> calls ?
> 
> Thanks,
> 
> Cimballi

Reply via email to