Why does executeUpdate not work a rollback in the service?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Why does executeUpdate not work a rollback in the service?

Igor Ussov
I have static transactional = true in the service and I run this method:

def move() {
    ...........................
    def lastAccumLeftCard =
salesLeftCard.toList().get(salesLeftCard.size() - 1).accumulation
    Sale.executeUpdate("update Sale s set s.accumulation =
(s.accumulation + :accum) where s.client = :cardRight",
            [accum: lastAccumLeftCard, cardRight: cardRight])
    Sale.executeUpdate("update Sale s set s.client = :cardRight where
s.client = :cardLeft",
            [cardRight: cardRight, cardLeft: cardLeft])
    throw Exception("Test rollback!")
}

But rollback doesn't happen. Why?

--
________________________________
Regards Igor

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Why does executeUpdate not work a rollback in the service?

Amit Jain-2

Hi Igor,

When Exception is thrown, transaction isn't rolled back. Rather throw RuntimeException and it should rollback then.



On Fri, Jan 14, 2011 at 4:14 PM, Igor Ussov <[hidden email]> wrote:
I have static transactional = true in the service and I run this method:

def move() {
   ...........................
   def lastAccumLeftCard =
salesLeftCard.toList().get(salesLeftCard.size() - 1).accumulation
   Sale.executeUpdate("update Sale s set s.accumulation =
(s.accumulation + :accum) where s.client = :cardRight",
           [accum: lastAccumLeftCard, cardRight: cardRight])
   Sale.executeUpdate("update Sale s set s.client = :cardRight where
s.client = :cardLeft",
           [cardRight: cardRight, cardLeft: cardLeft])
   throw Exception("Test rollback!")
}

But rollback doesn't happen. Why?

--
________________________________
Regards Igor

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Best Regards,
Amit Jain
IntelliGrape Software
Reply | Threaded
Open this post in threaded view
|

Re: Why does executeUpdate not work a rollback in the service?

Igor Ussov
With throw RuntimeException rollback also doesn't happen. Any ideas?

2011/1/14 Amit Jain <[hidden email]>:

>
> Hi Igor,
>
> When Exception is thrown, transaction isn't rolled back. Rather throw
> RuntimeException and it should rollback then.
>
>
>
> On Fri, Jan 14, 2011 at 4:14 PM, Igor Ussov <[hidden email]> wrote:
>>
>> I have static transactional = true in the service and I run this method:
>>
>> def move() {
>>    ...........................
>>    def lastAccumLeftCard =
>> salesLeftCard.toList().get(salesLeftCard.size() - 1).accumulation
>>    Sale.executeUpdate("update Sale s set s.accumulation =
>> (s.accumulation + :accum) where s.client = :cardRight",
>>            [accum: lastAccumLeftCard, cardRight: cardRight])
>>    Sale.executeUpdate("update Sale s set s.client = :cardRight where
>> s.client = :cardLeft",
>>            [cardRight: cardRight, cardLeft: cardLeft])
>>    throw Exception("Test rollback!")
>> }
>>
>> But rollback doesn't happen. Why?
>>
>> --
>> ________________________________
>> Regards Igor
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>
>
> --
> Best Regards,
> Amit Jain
> IntelliGrape Software
>



--
________________________________
Regards Igor

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Why does executeUpdate not work a rollback in the service?

burtbeckwith

Is the code really "throw RuntimeException("Test rollback!")"? That's not valid code, so it's probably generating a very different exception which isn't a runtime exception and doesn't trigger a rollback. It should be

throw new RuntimeException("Test rollback!")

Burt

> With throw RuntimeException rollback also doesn't happen. Any ideas?

>

> 2011/1/14 Amit Jain <[hidden email]>:

> >

> > Hi Igor,

> >

> > When Exception is thrown, transaction isn't rolled back. Rather throw

> > RuntimeException and it should rollback then.

> >

> >

> >

> > On Fri, Jan 14, 2011 at 4:14 PM, Igor Ussov <[hidden email]> wrote:

> >>

> >> I have static transactional = true in the service and I run this method:

> >>

> >> def move() {

> >>    ...........................

> >>    def lastAccumLeftCard =

> >> salesLeftCard.toList().get(salesLeftCard.size() - 1).accumulation

> >>    Sale.executeUpdate("update Sale s set s.accumulation =

> >> (s.accumulation + :accum) where s.client = :cardRight",

> >>            [accum: lastAccumLeftCard, cardRight: cardRight])

> >>    Sale.executeUpdate("update Sale s set s.client = :cardRight where

> >> s.client = :cardLeft",

> >>            [cardRight: cardRight, cardLeft: cardLeft])

> >>    throw Exception("Test rollback!")

> >> }

> >>

> >> But rollback doesn't happen. Why?

> >>

> >> --

> >> ________________________________

> >> Regards Igor

> >>

> >> ---------------------------------------------------------------------

> >> To unsubscribe from this list, please visit:

> >>

> >>    http://xircles.codehaus.org/manage_email

> >>

> >>

> >

> >

> >

> > --

> > Best Regards,

> > Amit Jain

> > IntelliGrape Software

> >

>

>

>

>