How to handle transaction?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to handle transaction?

Winster
Hi,

I want to store entities into database using
"delegator.create(genericValue)". I want to wrap this operation in a
transaction so that if any of the entity insert operation fails, rollback
all previous insert operations. How can I do that in OFBiz?

Thanks in advance
Winster T Jose
Director - Technology and Architecture
Chathurangam Creative Solutions Private Ltd.
Cell: +91-98469 31020
Mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to handle transaction?

Adrian Crum-3
If the operation is within a service, you don't need to worry about
handling transactions - the service engine does that for you.

-Adrian

On 2/22/2013 12:40 PM, Winster Jose wrote:

> Hi,
>
> I want to store entities into database using
> "delegator.create(genericValue)". I want to wrap this operation in a
> transaction so that if any of the entity insert operation fails, rollback
> all previous insert operations. How can I do that in OFBiz?
>
> Thanks in advance
> Winster T Jose
> Director - Technology and Architecture
> Chathurangam Creative Solutions Private Ltd.
> Cell: +91-98469 31020
> Mail: [hidden email]
>

Reply | Threaded
Open this post in threaded view
|

Re: How to handle transaction?

Winster
Thanks Adrian. Currently I am invoking the method from groovy directly. So,
I need to change the way I did, right?

On Fri, Feb 22, 2013 at 7:13 PM, Adrian Crum <
[hidden email]> wrote:

> If the operation is within a service, you don't need to worry about
> handling transactions - the service engine does that for you.
>
> -Adrian
>
>
> On 2/22/2013 12:40 PM, Winster Jose wrote:
>
>> Hi,
>>
>> I want to store entities into database using
>> "delegator.create(**genericValue)". I want to wrap this operation in a
>> transaction so that if any of the entity insert operation fails, rollback
>> all previous insert operations. How can I do that in OFBiz?
>>
>> Thanks in advance
>> Winster T Jose
>> Director - Technology and Architecture
>> Chathurangam Creative Solutions Private Ltd.
>> Cell: +91-98469 31020
>> Mail: [hidden email]
>>
>>
>


--
Winster T Jose
Director - Technology and Architecture
Chathurangam Creative Solutions Private Ltd.
Cell: +91-98469 31020
Mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to handle transaction?

Adrian Crum-3
How did you invoke Groovy?

-Adrian

On 2/22/2013 1:48 PM, Winster Jose wrote:

> Thanks Adrian. Currently I am invoking the method from groovy directly. So,
> I need to change the way I did, right?
>
> On Fri, Feb 22, 2013 at 7:13 PM, Adrian Crum <
> [hidden email]> wrote:
>
>> If the operation is within a service, you don't need to worry about
>> handling transactions - the service engine does that for you.
>>
>> -Adrian
>>
>>
>> On 2/22/2013 12:40 PM, Winster Jose wrote:
>>
>>> Hi,
>>>
>>> I want to store entities into database using
>>> "delegator.create(**genericValue)". I want to wrap this operation in a
>>> transaction so that if any of the entity insert operation fails, rollback
>>> all previous insert operations. How can I do that in OFBiz?
>>>
>>> Thanks in advance
>>> Winster T Jose
>>> Director - Technology and Architecture
>>> Chathurangam Creative Solutions Private Ltd.
>>> Cell: +91-98469 31020
>>> Mail: [hidden email]
>>>
>>>
>

Reply | Threaded
Open this post in threaded view
|

Re: How to handle transaction?

Deepak Agarwal-2
Hello Winster,

You need to call the service as :

dispatcher.runSync("MyService", map);

This way a new transaction is automatically created if there is no current
transaction in place.  If there was a transaction (in case of service
chain, one service calling to another service) a new transaction is not
created (unless in service definition you have mentioned to create a new
transaction always).

On Fri, Feb 22, 2013 at 9:41 PM, Adrian Crum <
[hidden email]> wrote:

> How did you invoke Groovy?
>
> -Adrian
>
>
> On 2/22/2013 1:48 PM, Winster Jose wrote:
>
>> Thanks Adrian. Currently I am invoking the method from groovy directly.
>> So,
>> I need to change the way I did, right?
>>
>> On Fri, Feb 22, 2013 at 7:13 PM, Adrian Crum <
>> adrian.crum@sandglass-**software.com <[hidden email]>>
>> wrote:
>>
>>  If the operation is within a service, you don't need to worry about
>>> handling transactions - the service engine does that for you.
>>>
>>> -Adrian
>>>
>>>
>>> On 2/22/2013 12:40 PM, Winster Jose wrote:
>>>
>>>  Hi,
>>>>
>>>> I want to store entities into database using
>>>> "delegator.create(****genericValue)". I want to wrap this operation in
>>>> a
>>>> transaction so that if any of the entity insert operation fails,
>>>> rollback
>>>> all previous insert operations. How can I do that in OFBiz?
>>>>
>>>> Thanks in advance
>>>> Winster T Jose
>>>> Director - Technology and Architecture
>>>> Chathurangam Creative Solutions Private Ltd.
>>>> Cell: +91-98469 31020
>>>> Mail: [hidden email]
>>>>
>>>>
>>>>
>>
>


--
Thanks,
Deepak Agarwal,

Mobile: +91 9501190044
Reply | Threaded
Open this post in threaded view
|

Re: How to handle transaction?

Winster
Thank you.
On 22 Feb 2013 21:51, "Deepak Agarwal" <[hidden email]> wrote:

> Hello Winster,
>
> You need to call the service as :
>
> dispatcher.runSync("MyService", map);
>
> This way a new transaction is automatically created if there is no current
> transaction in place.  If there was a transaction (in case of service
> chain, one service calling to another service) a new transaction is not
> created (unless in service definition you have mentioned to create a new
> transaction always).
>
> On Fri, Feb 22, 2013 at 9:41 PM, Adrian Crum <
> [hidden email]> wrote:
>
> > How did you invoke Groovy?
> >
> > -Adrian
> >
> >
> > On 2/22/2013 1:48 PM, Winster Jose wrote:
> >
> >> Thanks Adrian. Currently I am invoking the method from groovy directly.
> >> So,
> >> I need to change the way I did, right?
> >>
> >> On Fri, Feb 22, 2013 at 7:13 PM, Adrian Crum <
> >> adrian.crum@sandglass-**software.com <
> [hidden email]>>
> >> wrote:
> >>
> >>  If the operation is within a service, you don't need to worry about
> >>> handling transactions - the service engine does that for you.
> >>>
> >>> -Adrian
> >>>
> >>>
> >>> On 2/22/2013 12:40 PM, Winster Jose wrote:
> >>>
> >>>  Hi,
> >>>>
> >>>> I want to store entities into database using
> >>>> "delegator.create(****genericValue)". I want to wrap this operation in
> >>>> a
> >>>> transaction so that if any of the entity insert operation fails,
> >>>> rollback
> >>>> all previous insert operations. How can I do that in OFBiz?
> >>>>
> >>>> Thanks in advance
> >>>> Winster T Jose
> >>>> Director - Technology and Architecture
> >>>> Chathurangam Creative Solutions Private Ltd.
> >>>> Cell: +91-98469 31020
> >>>> Mail: [hidden email]
> >>>>
> >>>>
> >>>>
> >>
> >
>
>
> --
> Thanks,
> Deepak Agarwal,
>
> Mobile: +91 9501190044
>